Question

In: Computer Science

uniprocessor system

Consider the following program:

 

Note that the scheduler in a uniprocessor system would implement pseudo parallel execution of these two concurrent processes by interleaving their instructions, without restriction on the order of the interleaving.

a. Show a sequence (i.e., trace the sequence of inter-leavings of statements) such that the statement “x is 10” is printed.

b. Show a sequence such that the statement “x is 8” is printed. You should remember that the increment/decrements at the source language level are not done atomically, that is, the assembly language code:

 

Implements the single C increment instruction (x = x + 1).

Solutions

Expert Solution

a.

For "x is 10", the interleaving producing the required behavior is easy to find since it requires only an interleaving at the source language statement level. The essential fact here is that the test for the value of x is interleaved with the increment of x by the other process. Thus, x was not equal to 10 when the test was performed, but was equal to 10 by the time the value of x was read from memory for printing.

 

P1: x = x - 1;

M(x)

 

9

 

P1: x = x + 1;

10

 

P2: x = x - 1;

9

 

P1: if(x != 10)

9

 

P2: x = x + 1;

10

 

P1: printf("x is %d", x);

10

 

 

"x is 10" is printed.

 

 

b.

For "x is 8" we need to be more inventive, since we need to use inter-leavings of the machine instructions to find a way for the value of x to be established as 9 so it can then be evaluated as 8 in a later cycle. Notice how the first two blocks of statements correspond to C source lines, but how later blocks of machine language statements interleave portions of a source language statement. 


For "x is 8" we need to be more inventive, since we need to use inter-leavings of the machine instructions to find a way for the value of x to be established as 9 so it can then be evaluated as 8 in a later cycle. Notice how the first two blocks of statements correspond to C source lines, but how later blocks of machine language statements interleave portions of a source language statement. 

Related Solutions

Different systems (such as the circulatory system, digestive system, respiratory system, urinary system, skeletomuscular system, etc.)...
Different systems (such as the circulatory system, digestive system, respiratory system, urinary system, skeletomuscular system, etc.) cooperatively regulate homeostasis. Describe a homeostatic regulation that involves two or more different systems (except using only the nervous system and the endocrine system). (8 pts) Please answer the questions below in great detail!!! All questions below correlate to the 8pt question above. In total, there should be one response but divided into smaller pieces. Name the homeostatic function to be regulated. (1 pt)...
-Endocrine system - Nerve system - Cardiovascular system - Digestive system What are their primary organs...
-Endocrine system - Nerve system - Cardiovascular system - Digestive system What are their primary organs and functions? What are some primary lifestyle choices to help live a healthier life? What are some risk factors to avoid for a healthier life?
System,control system and signal
Describe briefly system,control system and signal, with some examples.
* ERP system of HR system??
* ERP system of HR system??
This is a two-system chapter. Decide on either the nervous system or the endocrine system for...
This is a two-system chapter. Decide on either the nervous system or the endocrine system for your report. Write about some disease or condition that is new to you and add some personal comments. 1. Submit your report 2. Participate in the Discussion
1. respiratory system 2. cardiovascular system
1. respiratory system2. cardiovascular system3. nervous system4. endocrine system5. urinary System
Discuss the negative feedback system of the endocrine system.
1. Discuss the negative feedback system of the endocrine system. Describe what actions cause the feedback system to be initiated and shut off.3. Describe the pathophysiology, clinical manifestations, diagnostic test, complications and treatment of pituitary, thyroid, parathyroid, pancreatic and adrenal endocrine disorders. (Graves' disease, Addison's disease, acromegaly, gigantism, dwarfism, adrenal insufficiency, SIADH, diabetes, thyrotoxicosis, myexedema, diabetes insipitus, Cushing's disease/syndrome, somogyi, dawn phenomenon
If the wavefunction for a system is a superposition of wavefunction, the wavefunction of the system...
If the wavefunction for a system is a superposition of wavefunction, the wavefunction of the system cannot be determined. Explain this statement.
Briefly describe the Linnaeus system or binomial system
Briefly describe the Linnaeus system or binomial system
discuss the idea about cardiovascular system and respiratory system disorders, and the association of cardiovascular system...
discuss the idea about cardiovascular system and respiratory system disorders, and the association of cardiovascular system and respiratory system with each other.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT