Term
CRITICAL SECTION - CONCEPT |
|
Definition
Each process has a segment of code, called a critical section, in which the process may be changing common variable, updating a table, writing a file, and so on . The important feature of the system is that , when one process is executing in its critical section, no other process is to be allowed to execute in its critical section. |
|
|
Term
|
Definition
multiple processes try to access the same piece of data at the SAME time |
|
|
Term
WHAT IS A CRITICAL SECTION ? |
|
Definition
SEGMENT OF CODE IN A PROCESS IN WHICH THE PROCESS MAY BE CHANGING COMMON VARIABLES, UPDATING A TABLE, WRITING A FILE, AND SO ON... |
|
|
Term
|
Definition
ONLY ONE PROCESS AT A TIME CAN USE THE RESOURCE, IF ANOTHER PROCESS REQUESTS THAT RESOURCE, THE REQUESTING PROCESS MUST WAIT |
|
|
Term
THREE COMPONENTS OF A SOLUTION FOR SYNCHRONIZATION ? |
|
Definition
MUTUAL EXCLUSION
PROGRESS - IF NO PROCESS IS EXECUTING IN IT'S C.S. AND SOME PROCESSES WISH TO ENTER THEIR C.S., THEN ONLY THOSE PROCESSES THAT ARE NOT EXECUTING IN THEIR REMAINDER SECTIONS CAN PARTICIPATE IN THE DECISION ON WHICH WILL ENTER ITS CRITICAL SECTION NEXT
BOUNDED WAITING - THERE EXISTS A BOUND, OR LIMIT, ON THE NUMBER OF TIMES THAT OTHER PROCESSES ARE ALLOWED TO ENTER THEIR C.S. AFTER A PROCESS HAS MADE A REQUEST TO ENTER ITS C.S. |
|
|
Term
BUSY WAITING
(IN TERMS OF PROCESS SYNCH) |
|
Definition
WHILE A PROCESS IS IN ITS C.S. ANY OHTER PROCESS THAT TRIES TO ENTER ITS C.C. MUST LOOP CONTINUOUSLY IN THE ENTRY CODE. |
|
|
Term
|
Definition
PROCESS "SPINS" WHILE WAITING FOR A LOCK TO ACCESS THE C.S. OF ITSELF |
|
|
Term
DESCRIBE THE THREE USER-LEVEL SOLUTION FOR PROCESS SYNCHRONIZATION |
|
Definition
"TURN" SOLUTION - THE PROCESSES TAKE TURNS *NOT A GOOD ALGORITHM BECAUSE IT WILL BLOCK PROC A IF IT WANTS TO ACCESS DATA TWICE IN A ROW
"INTEREST[]" SOLUTION - NOT A GOOD SOLUTION BECAUSE IT CAN CAUSE A DEADLOCK
"PETERSON'S SOLUTION" - INTERESTA = 0; TURN=1; WHILE((TURN==1) && (INTERESTB==1) {} C.S. INTERESTA=0;
PETERSON'S SOLUTION HAS TRUE MUTUAL EXCLUSION |
|
|
Term
WHAT ARE SOME SYSTEM-LEVEL SOLUTIONS FOR PROCESS SYNCHRONIZATION ? |
|
Definition
SEMAPHORE - USES WAIT() AND SIGNAL()
COUNTING SEMAPHORE - CAN RANGE OVER AN UNRESTRICTED DOMAIN
BINARY SEMAPHORE - CAN RANGE ONLY BETWEEN 1 AND 0 |
|
|
Term
HOW DO YOU USE JAVA MONITOR LOCK TO PROTECT A C.S. FROM RACE CONDITION ?
(USE JAVA CODE TO EXPLAIN) |
|
Definition
CLASS FOO(){ int FOO(myLock){ Synchronize(myLock){ C.S. } } CLASS LOCKER { int main(args){ Object myLock = new Object(); FOO newFoo = new FOO (myLock); } } |
|
|
Term
HOW DO YOU USE PETERSON'S ALGORITHM TO AVOID THE RACE CONDITIONS AMONG TWO CONCURRENT THREADS ? |
|
Definition
THREAD A:
FLAG=TRUE; TURN=I; WHILE(FLAG==TRUE && TURN == I){ C.S. } FLAG=FALSE; }
THREAD2: FLAG = TRUE; TURN = 1; WHILE(FLAG==TRUE && TURN == J){ C.S. FLAG=FALSE; } |
|
|