1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
attashe74 [19]
3 years ago
10

Design an algorithm for a bounded-buffer monitor in which the buffers (portions) are embedded within the monitor itself."

Computers and Technology
1 answer:
sattari [20]3 years ago
5 0

Answer:

Required code is given below:

Explanation:

monitor bounded buffer {

int items[MAX ITEMS];

int numItems = 0;

condition full, empty;

void produce(int v)

{

while (numItems == MAX ITEMS) full.wait();

items[numItems++] = v;

empty.signal();

}

int consume()

{

int retVal;

while (numItems == 0) empty.wait();

retVal = items[--numItems];

full.signal();

return retVal;

}

}

You might be interested in
You are tasked to calculate a specific algebraic expansion, i.e. compute the value of f and g for the expression: ???? = (??????
melisa1 [442]

Answer:

.data

prompt: .asciiz "Enter 4 integers for A, B, C, D respectively:\n"

newLine: .asciiz "\n"

decimal: .asciiz "f_ten = "

binary: .asciiz "f_two = "

decimal2: .asciiz "g_ten = "

binary2: .asciiz "g_two = "

.text

main:

#display prompt

li $v0, 4

la $a0, prompt

syscall

#Read A input in $v0 and store it in $t0

li $v0, 5

syscall

move $t0, $v0

#Read B input in $v0 and store it in $t1

li $v0, 5

syscall

move $t1, $v0

#Read C input in $v0 and store it in $t2

li $v0, 5

syscall

move $t2, $v0

#Read D input in $v0 and store it in $t3

li $v0, 5

syscall

move $t3, $v0

#Finding A^4

#Loop (AxA)

li $t6, 0

L1:

bge $t6, $t0, quit

add $s1, $s1, $t0 # A=S+A => $s1= A^2

addi $t6, $t6, 1 # i=i+1

j L1

quit:

#Loop (A^2 x A^2)

li $t6, 0

L1A:

bge $t6, $s1, quit1A

add $s5, $s5, $s1

addi $t6,$t6, 1

j L1A

#End of Finding A^4

#Finding 4xA^3

quit1A:

#Loop (4xB)

li $t6, 0

L2:

bge $t6, 4, quit2

add $s2, $s2, $t1

addi $t6, $t6, 1

j L2

quit2:

#Loop (BxB)

li $t6 , 0

L2A:

bge $t6, $t1, quit2A #loop2

add $s6, $s6, $t1 #add

addi $t6, $t6, 1 #add immediate

j L2A #loop2

quit2A: # perform proper program termination using syscall for exit

#Loop (BxB)

li $t6 , 0 #load immediate

L2AA:

bge $t6, $s2, quit2AA #loop2

add $t7, $t7, $s6 #add

addi $t6, $t6, 1 #add immediate

j L2AA #loop2

#End ofFinding 4xA^3

#Finding 3xC^2

quit2AA: # perform proper program termination using syscall for exit

#3 Loop (3 x (C x C)) FOR S3

li $t6 , 0 #load immediate

L3:

bge $t6, $t2, quit3 #loop3

add $s3, $s3, $t2 #add

addi $t6,$t6, 1 #add immediate

j L3 #loop3

quit3: # perform proper program termination using syscall for exit

#3 Loop (3 x (C x C)) FOR S3

li $t6 , 0 #load immediate

L3A:

bge $t6, 3, quit3A #loop3

add $s0, $s0, $s3 #add

addi $t6,$t6, 1 #add immediate

j L3A #loop3

#End of Finding 3xC^2

#Finding 2xD

quit3A: # perform proper program termination using syscall for exit

#4 Loop (2 x D) FOR S4

li $t6 , 0

L4:

bge $t6, 2, quit4 #loop4

add $s4, $s4, $t3 #add

addi $t6, $t6, 1 #add immediate

j L4 #Loop4

#End of Finding 2xD

#Finding AxB^2

quit4:

li $t6, 0

li $s1, 0

L5:

bge $t6, $t1, quit5

add $s1, $s1, $t1

addi $t6, $t6, 1

j L5

quit5:

li $t6, 0

li $s2, 0

L6:

bge $t6, $t0, quit6

add $s2, $s2, $s1

addi $t6, $t6, 1

j L6

#End of Finding AxB^2

#Finding C^2XD^3

quit6: #finds C^2

li $t6, 0

li $s1, 0

L7:

bge $t6, $t2, quit7

add $s1, $s1, $t2

addi $t6, $t6, 1

j L7

quit7: #finds D^2

li $t6, 0

li $s6, 0

L8:

bge $t6, $t3, quit8

add $s6, $s6, $t3

addi $t6, $t6, 1

j L8

quit8: #finds D^3

li $t6, 0

li $s7, 0

L9:

bge $t6, $t3, quit9

add $s7, $s7, $s6

addi $t6, $t6, 1

j L9

quit9: #finds C^2XD^3

li $t6, 0

li $s3, 0

L10:

bge $t6, $s1, end

add $s3, $s3, $s7

addi $t6, $t6, 1

j L10

#End of Finding C^2XD^3

end: # perform proper program termination using syscall for exit

#f is $t8

li $t8 , 0

sub $t8, $s5, $t7 # addition

add $t8, $t8, $s0 # subract

sub $t8,$t8, $s4 # subract

#g is $t9

li $t9 , 0

add $t9, $s2, $s3 # addition

#Display

#1st equation

li $v0,4 # display the answer string with syscall having $v0=4

la $a0, decimal # Gives answer in decimal value

syscall # value entered is returned in register $v0

li $v0, 1 # display the answer string with syscall having $v0=1

move $a0, $t8 # moves the value from $a0 into $t8

syscall # value entered is returned in register $v0

li $v0,4 # display the answer string with syscall having $v0=4

la $a0, newLine # puts newLine in between answers

syscall # value entered is returned in register $v0

li $v0,4 # display the answer string with syscall having $v0=4

la $a0, binary # Gives answer in binary

syscall # value entered is returned in register $v0

li $v0, 35

move $a0, $t8 # moves the value from into $a0 from $t8

syscall # value entered is returned in register $v0

li $v0,4 # display the answer string with syscall having $v0=4

la $a0, newLine # puts newLine in between answers

syscall # value entered is returned in register $v0

#2nd equation

li $v0,4 # display the answer string with syscall having $v0=4

la $a0, decimal2 # Gives answer in decimal value

syscall # value entered is returned in register $v0

li $v0, 1 # display the answer string with syscall having $v0=1

move $a0, $t9 # moves the value from $a0 into $t8

syscall # value entered is returned in reg $v0

li $v0,4 # display the answer string with syscall having $v0=4

la $a0, newLine # puts newLine in between answers

syscall # value entered is returned in register $v0

li $v0,4 # display the answer string with syscall having $v0=4

la $a0, binary2 # Gives answer in binary

syscall # value entered is returned in register $v0

li $v0, 35

move $a0, $t9 # moves the value from into $a0 from $t8

syscall # value entered is returned in register $v0

li $v0,4 # display the answer string with syscall having $v0=4

la $a0, newLine # puts newLine in between answers

syscall # value entered is returned in register $v0

#end the program

li $v0, 10

syscall

8 0
2 years ago
Where can I easily find an easy app or program to use for making/editing videos?
GalinKa [24]
I think imovie is a good editing app for free. It is in the apple app store.  Most editing programs are not for free
6 0
3 years ago
Early computers took up entire rooms. which of these dramatically reduced the size of computers? microchips sound recording comp
tigry1 [53]

Answer:

Micro chips

Explanation:

The evolution of computers to the modern day is made possible due to the micro chips or modern transistors or super efficient silicon integrated circuits The micro chips replaced the valves or vacuum tubes that made earlier computers have an enormous size.

3 0
2 years ago
What will be printed when the following code is executed? int y = 10; if ( y == 10) { int x = 30; x += y; } cout<<"x = ";
Alja [10]

Answer:

I don't know the answer

5 0
3 years ago
A team of researchers wants to create a program to analyze the amount of pollution reported in roughly 3,000 counties across the
omeli [17]

The option that is most likely to be a challenge in creating the program is Different counties may organize data in different ways.

<h3>What is Pollution?</h3>

Pollution is known to be a kind of bringing in of harmful materials into an environment.

These harmful things are known as pollutants. Pollutants are known to be natural and artificial that is they are created by human activity, such as trash or runoff produced by factories, etc.

Learn more program from

brainly.com/question/1538272

7 0
2 years ago
Other questions:
  • in c Write a program that reads an integer, a list of words, and a character. The integer signifies how many words are in the li
    14·1 answer
  • Your instructor has asked you to perform some research regarding a computer OS capability of distinguishing spoken words. What i
    14·1 answer
  • Give big-O estimate for the number of operations (multiplication or addition) used in the following algorithm segment (ignore co
    15·1 answer
  • What is an entity supertype, and why is it used?
    6·1 answer
  • Which statements describe the use of styles in Word? Check all that apply.
    11·2 answers
  • A(n) ________ is a chart based on PivotTable data.
    15·1 answer
  • What does the poster exemplify?
    15·2 answers
  • What are the positive impact of computer in society
    8·1 answer
  • Describe the layout of an article on Wikipedia​
    7·1 answer
  • In a print statement, you can set the __________ argument to a space or empty string to stop the output from advancing to a new
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!