Use LEFT and RIGHT arrow keys to navigate between flashcards;
Use UP and DOWN arrow keys to flip the card;
H to show hint;
A reads text to speech;
25 Cards in this Set
- Front
- Back
What is an atomic action? Give an example of an atomic action.
|
executes in an all-or-nothing mode, with invisible intermediate states, with a well defined behavior
Read/Load instruction from physical memory as an atomic operation, and the same for Write/Store |
|
What is a barrier?
|
Special instructions, called barriers can be used to ensure that all instructions occurring before a barreer complete before the instructions following it execute
|
|
What is another name for interleavings?
|
Schedules
|
|
What is serial interleaving?
|
one where all the operations of one activity precede all the operations of the other activity.
|
|
What is the important concept of interleaving?
|
that it allows us to express the meaning of concurrent programs: The parallel execution of activities is equivalent to the sequential execution of one of the interleavings of these activities
|
|
When is a set of activities (i.e. program) Determinate?
|
if any time it runs, for the same inputs, it gives the same outputs
|
|
How do you prevent the occurrence of the interleavings?
|
SYNCHRONIZATION MECHANISMS
|
|
What is the Bernsteins Conditions used for?
|
Used to determine if a program is determinate.
|
|
State the Bernstein's Condition.
|
Given activities P and Q, if
The intersection of W(P) with W(Q) is empty, and The intersection of W(P) with R(Q) is empty, and The intersection of R(P) with W(Q) is empty then The parallel execution of P and Q is determinate. (Note: if these conditions are still not true, it is possible that the parallel execution of P and Q, is determinate. |
|
Why do computers have (at least) two modes, a user
mode and a kernel mode? |
For Resource Management
|
|
What is preemptive?
|
If there is a mechanism to stop processes, then the scheduling is preemptive
|
|
When a process stops or is stopped, the registers have to be copied into where?
|
Process control block (PCB)
|
|
What is round robin scheduling?
|
A scheduling algorithm that allows Each process to run for a fixed maximum time before it is stopped. This fixed time must be carefully tuned. If it is too long, then response time for processes currently not running is too slow. If the time is too short, then the system will spend proportionally more time swapping processes and will just appear to be running slowly.
|
|
Spinlocks use Busy Waiting, which is negative. What nice things can you say about spinlocks?
|
1) can protect regions by locking then unlocking a critical area
2) User mode instruction - No system overhead |
|
In a monitor we can use Condition Variables.
a. What are their operations and what are their effects. |
Their operations are used for scheduling accesses to shared resources, such as the bounded buffer in the producer- consumer program.
are used only to allow processes that do not want to continue at this point, to get out of the way to allow other processes to run |
|
Why it is not safe to print within a signal handler
|
The main reason is because in asynchronous signals the signal handler's print may happen in the middle of a normal print.
|
|
Do threads share the same standard C buffer?
|
The answer is yes. But one can play tricks: the unix call "openfd" goes from file descriptor (int), to file pointer (FILE *) and creates a new buffer, as demonstrated by this example. Thus if you like in each thread you can have your own buffer to the terminal. That will be safe as long as you write single lines. If you want to write atomically a block of lines you will need to use locks.
|
|
Implement in C the function int indexOf(const char *s, cost char *who, int k)
which, given a string s, returns the position of the first occurrence of who in s at or after position k. For example indexOf("roses are red", "re", 9) is 10. You cannot use any standard C function (you can use strlen). |
int indexof(const char *s, const *who, int k){
int n = strlen(s); int m = strlen(who); int j,i; for(j=k; j<=n-m;j++){ for(i=0;i<m;i++) if(who[i]!=j[j+i] goto outer; return j; outer ; } |
|
How does one go from user mode to kernel mode?
|
user->kernel mode is done by a system call
|
|
What are condition variables?
|
Special variables with two operations: wait and signal
|
|
Explain in detail then for each of the following operations indicate if it should be done in user
or kernel mode: (1) Read the time of day clock (2) Set the time of day clock (3) Start an IO operation (4) Disable interrupts |
read time of day: user or kernel - read only operation
set the time of day: system start an IO operation: sys Disable interrupts: sys otherwise user could take control of the machine |
|
e
|
e
|
|
e
|
e
|
|
e
|
e
|
|
e
|
e
|