Computer Science 422/622 Quiz 0 - Name ____________________ 1. Identify the correct class of OS for each of the following example systems: (task == process). 1. Single-user single-task ____ a. Windows NT/2000 2. Single-user multi-task ____ b. MS-DOS 3. Multi-user single-task ____ c. Windows 95/98/ME 4. Multi-user multi-task 2. Which of the following is NOT one of the three O/S objectives in resource management a. Fairness b. Safety c. Obscurity d. Efficiency 3. From the perspective of the END-USER which of the following pairs of OS classes appear to be MOST SIMILAR in functionality a. Single-user single-task b. Single-user multi-task Single-user multi-task Multi-user multi-task c. Multi-user multi-task Multi-user multi-task multi-processor Computer Science 422/622 Quiz 1 Name _____________________ 1. For each of the following OS design approaches identify the associated disadvantage of its use. ___ 1. Monolithic a. The passing of messages required by the object orientation led to some sloowwww running. ___ 2. Hierarchical b. Contention for access to shared global variables led to slow system performance. ___ 3. Process / Object oriented c. It was very difficult to classify OS modules in a way that avoided dependency cycles d. The heavy use of global variables made it difficult to fix or enhance the system without introducing bugs. 2. The design used in the Linux version of Unix is: a. Hierarchical b. Monolithic c. Process / Object Oriented 3. Suppose an application process contains the following code sequence L AX,counter ;Load value of counter from memory into reg AX ADDI AX,16 ;Increment contents of reg AX by 16 ST AX,counter ;Store updated value back in memory Which of the following best describes the role of the OS (such as Linux, Solaris, or Win 2K) during the execution of this code sequence. a. The OS executes each instruction b. Since there is only one set on behalf on the application of hardware registers, the OS must perform register updates on behalf of the application c. Since memory must be protected d. Both b. and c. are true against broken and malicious but not a. programs, it is necessary for the OS to perform memory accesses on behalf of the application. e. If the program is correct and non-malicious there is no OS involvement at all. Computer Science 422/622 Quiz 2 - Name ____________________ 1. Which of the following hypothetical instructions MUST be privileged in order to ensure safe operation in the presence of broken or malicious user programs: a. Enable interrupts b. Set User Mode bit (Enter user mode) c. Disable interrupts d. Clear User Mode bit (Enter kernel mode) e. c. and d. (but not a. and e.) f. all of the above 2. When an interrupt does occur the Pushing of the IP and Flags registers onto the stack is performed by: a. The interrupted application b. The O/S c. By the hardware w/o O/S or application involvement 3. The interrupt address table (which contains the address of interrupt handlers) is constructed by: a. Application programs b. The O/S c. Automatically by the hardware 4. Suppose a malicious hacker tries to crash a unix system by running the following program: main() { asm cli; while (1); } When the hacker tries to compile and execute it. Which of the following best describes what will occur. a. The hackers attempt to build b. The hacker can build an a.out an a.out will fail because users and when he starts it the system aren't allowed to write in assembly. will crash. c. The hacker's a.out will loop d. The hacker's a.out will be indefinitely but other processes terminated the first time will be dispatched whenever the it attempts to execute the hacker's is preempted. cli instruction. 5. Suppose the hacker removes the "asm cli" statement. Which of the following now best decribes what will happen: a. The hackers will get a compile b. The hacker can build an a.out time error because of the presence and when he starts it the system of an infinite loop. will crash. c. The hacker's a.out will loop d. The hacker's a.out will be indefinitely but other processes terminated the first time will be dispatched whenever the it attempts to execute the hacker's is preempted. cli instruction. Computer Science 422/622 Quiz 3 Name _____________________ We considered a time line like the following one in class last time: Proc A ------ ----- ------ Proc B ------ ----- OS --- --- ---- ----- 1. The relative lengths of the ---- lines shown above are: a. Realistic reflections of b. Wrong.. The user lines should a typical system behavior be longer c. Wrong.. The OS lines should d. Wrong.. All --- lines should have be longer. EXACTLY the same length. 2. Which of the following does NOT occur WITHIN the VERTICAL period of transition from APP to OS or OS to APP another a. Push IP and Flags on stack b. Clear User mode bit in Flags c. Save SP in process PCB d. Load IP from Interrupt address table 3. The mechanism used to effect a transfer of control from a running application to the operating system is: a. a subroutine call b. an interrupt instruction c. an iret instruction d. Both (a.) and (b.) are used 4. The mechanism used to effect a transfer of control from the operating system is back to a user application is a. a subroutine call b. an interrupt instruction c. an iret instruction d. Both (a.) and (b.) are used 5. In the multiasking model that we discussed in class, OS code runs: a. each time a switch between b. only after all tasks have two application tasks occurs. had a chance to run. c. after each instruction is d. only when there are no executed by an application. applications available to run. Computer Science 422/622 Quiz 4 - Name ____________________ 1. The maximum number of processes that can be in the run state at any instant can be as large as but not exceed: a. 1 b. the number of presently existing processes c. the number of processors d. Unlimited. in the computer system. 2. The maximum number of processes that can be in the ready state at any instant can be as large as but not exceed: a. 1 b. the number of presently existing processes c. the number of processors d. Unlimited. in the computer system. 3. The data structure used to represent the static structure relationship among processes is the: a. Stack b. Linked list c. Binary tree d. General tree 4. Which of the following state transitions would be made MOST OFTEN by a process that did a tremendous amount of computation but no I/O at all. a. Running to Ready b. Blocked to Ready c. Running to Blocked d. Running to zombie 5. The transition commonly called "Scheduling or Dispatching" involves a process changing between which two states. a. Ready to Running b. Running to Ready c. Running to Blocked d. Blocked to Ready Computer Science 422/622 Quiz 5 - Name ____________________ 1. The data structure used to represent the dynamic structure in process management is the: a. Stack b. Linked list c. Binary tree d. General tree 2. The assembly language instruction used to make an OS system call in Linux on an Intel processor is: a. CALL b. JSR c. INT d. IRET 3. It is commonly the case for a Unix system to have 50 or more existing processes. At any instant in time most of these processes are in which state: a. RUN b. READY c. BLOCKED d. ZOMBIE 4. The value pushed on the stack JUST BEFORE an OS system call interrupt is made in Linux is: a. The last parameter to b. The first parameter to be passed to the OS be passed to the OS c. The ID # of the system d. The PID of the process call being requested. making the system call. 5. Which of the following would NOT be an input parameter when an application makes the create_process( ) system call. a. Name of a program to run. b. Addr of the PCB for the new process c. Priority of the new process. Computer Science 422/622 Quiz 6 - Name ____________________ 1. When a Unix process forks() the child process begins execution a. At the line of code just beyond b. At the start of the program the call to fork() containing the fork() c. At the first line of the d. At the start of the C function executable program specified specified in the fork() in the fork() call call. 2. How many new processes (EXCLUDING THE ORIGINAL PARENT) will be created by: for (i = 0; i < 3; i++) fork(); main() { int x = 5; rc = fork(); x = 14; if (rc != 0) |------> else { | { sleep(10); | x = 77; printf("%d\n", x); | sleep(1); | printf("%d\n", x); } ----------------| } 3. What numeric value will be printed by the parent? 4. What numeric value will be printed by the child? 5. Which of the following is/are NOT a proper way to invoke the "wait" system call in Unix. (Identify ALL that are improper). int status; a. wait(0); b. wait(status); c. wait(); d. wait(&status); Computer Science 422/622 Quiz 7 - Name ____________________ 1. The input parameter(s) passed INTO the pipe system call is/are: a. The PID of the process to b. A pointer to an array which to connect the pipe. of two integers. c. A integer value representing d. None of the above... pipe the pipe handle and another like fork has no parameters. integer value representing the capacity of the pipe. 2. If a parent and child process are to communicate via a pipe the pipe() system call should be made: a. before the fork() b. after the fork() c. it makes no difference. 3. For a process to receive an End-of-file indication on reading a pipe, it is necessary that: a. at least one other process b. all other processes that that has an open write handle have the pipe open for reading close the write handle. close the read handle c. all other process that have an open write handle close the write handle. Consider the following code segment: 1 pipe(pd); ----------> 8 close(pd[1]); 2 rc = fork(); | 9 rc = fork(); 3 if (rc == 0) | 10 if (rc == 0) 4 { | 11 { 5 c1(pd); | 12 c2(pd); 6 exit(1); | 13 exit(1); 7 } ---------- 14 } 15 wait(&status); 16 wait(&status); 4. Suppose the close(pd[1]) is moved from its location at line 8 and inserted between lines 9 and 10. In this case, after the c1 function closes pd[1], a. the c2 function will get b. the c2 function will not eof if it tries to read get eof if it tries to read the pipe. the pipe. 5. Suppose the close(pd[1]) is moved from its location at line 8 and inserted between lines 2 and 3. Which best describes the situation now.. a. the c1 function will not b. the c1 function will be able be able to write into the to write and the c2 function will the pipe. get eof when c1 closes pd[1]. c. the c1 function will be able to write but the c2 function will not get eof when c1 closes pd[1]. Computer Science 422/622 Quiz 8 - Name ____________________ 1. Of the three schedulers that we identified, the only one that could be classified as non-preemptive is: a. the dispatcher b. the swapper c. the batch job scheduler 2. The medium-term scheduler is also known as a. the dispatcher b. the swapper c. the batch job scheduler 3. On a "normal" computer system dispatch level scheduling occurs a. 100's of times per second c. about once a second c. about once an hour d. about once a day 4. Which of the following system calls is NOT guaranteed to cause a short term scheduling event to occur: a. sleep(10); b. fork(); c. exit(1); 5. On a "normal" computer system the dispatch level scheduler selects for scheduling: a. A process that is randomly b. The process at the head selected from the Ready list of the ready list c. The process that has not been scheduled in the longest amount of time. Computer Science 422/622 Quiz 9 - Name ____________________ 1. Which of the following is a "normal" performance objective a. high throughtput and b. low throughput and high response time high response time c. high througput and d. low throughput and low response time low response time 2. As the number of users of a transaction processing system gets larger and larger, transaction throughput and response time behave as: a. throughput -> infinity b. throughput -> 0 response -> infinity response -> infinity c. throughput -> infinity d. throughput -> fixed upper bound response -> fixed upper response -> infinity bound. Suppose a small transaction processing system is being run on a personal computer class system. Each transaction requires 0.05 seconds of CPU time and 0.20 seconds of disk time. 3. What is the maximum throughput in transactions per second a. 0.05 b. 0.2 c. 20 d. 5 4. What is the "bottleneck" device a. cpu b. disk c. both contribute equally 5. Suppose the CPU is replaced by a new processor that is 4 times as fast, but the disk is not changed. Which best describes the consequences: a. max throughput increases and b. max througput stays the same but min response time decreases min response time decreases c. max throughput decreases and b. max througput stays the same but min response time decreases min response time increases Computer Science 422/622 Quiz A Name__________________________ Suppose 3 jobs arrive at the same time to a system that uses non-preemptive FCFS scheduling. Each job requires 15 minutes of running time. 1. What is the average RESPONSE time for the 3 jobs 2. What is the average WAITING time for the 3 jobs. Suppose PS (Processor Sharing) scheduling is used and three jobs arrive at the same time. One job requires 6 minutes of CPU time, one requires 10 minutes, and the other requires 16 minutes. All three jobs begin execution at time T = 0. 3. At what time will the 1st job complete? T = 4. At what time will the last job complete? T = 5. What will be the average response time of the three jobs? Computer Science 422/622 Quiz B Name__________________________- 1. Suppose 2 jobs both require 10 minutes of CPU time and 5 minutes of DISK time. What will the AVERAGE response time be if they are run using MSDOS style non-preemptive FCFS scheduling. (Assume a program can NOT overlap its OWN cpu activity with its OWN disk activity). 2. Now suppose they are run concurrently using RR scheduling and optimal overlap IS achieved. What will be the average response time. 3. If these two jobs do achieve optimal overlap, the percent of time the disk and CPU will be busy is: a. 100% for both b. 50% for CPU - 100% for DISK c. 100% for CPU - 50% for DISK d. 50% for both 4. In "Real World" scheduling, when processes have equal priority the algorithm used to schedule them is: a. First come first served (FCFS) b. Round robin (RR) c. Shortest job first (SJF) d. Last come first served (LCFS) 5. In "Real World" scheduling, a process is given a higher priority when: a. It doesn't use much CPU time b. It uses much CPU time and before suspending itself. rarely suspends itself. c. It uses a lot of memory. d. It doesn't do much Disk I/O Computer Science 422/622 Quiz C Name__________________________- 1. A typical process will be: a. Swapped more often than b. Dispatched more often than it will be dispatched swapped c. Swapped and dispatched the same number of times. <<< Here it is!>>> 2. When a process is suspended waiting for a single disk I/O to complete: a. It would typically be b. It would typically be swapped swapped out and in out and in once. several times. c. It would typically not be swapped out at all. 3. Which of the following would NOT be a good reason for the swapper to select a process for swapping OUT. a. The process is in the b. The process is using a large suspended rather than amount of memory. the ready state. c. The process has low d. The process has not been dispatched priority since it was last swapped in. 4. Which of the following would NOT be a factor in selecting which process to swap in: a. The priority of the process b. How much memory it used c. How much CPU time it had d. Whether it was out blocked or consumed since it was swapped out ready. out. 5. We said that the maximum rate swaps should occur on a multiuser OS/390 or Unix system is about a. 1 swap per day b. 1 swap per hour c. 1 swap per second d. 1 swap per millisecond Computer Science 422/622 Quiz D Name__________________________- 1. Consider the following code segment: int a = 0; |---> for (c = 0; c < 100000; c++) void xthread( | a = a + 1; int x, | int y) | } { | int c, d; --------- Suppose two threads are created and both run the function xthread which of the following BEST characterizes the sharing of data. a. The variable 'a' is shared b. 'a' and 'x' are shared but but both threads have private 'c' is private. copies of 'x' and 'c'. c. All five variables are shared d. all five variables are private. (i.e. if either thread changes one of them, the change is seen by the other thread. 2. Suppose the above function is run concurrently as 4 separate threads. After all threads complete the value of "a" will be: a. somewhat less than 400000 b. somewhat greater than 400000 or possibly even equal to or possibly even equal to 400000 400000 c. exactly 100000 d. exactly 400000 3. Which of the following values you typically NOT be specified in a system call used to create a thread: a. The address of the function to b. Parameter to be passed into be executed in the context of the function. the new thread. c. The size of the new address d. The address or size of the stack space to be created for the to be used by the new thread. thread. 4. When a new thread is created using pthread_create, execution of the new thread begins at: a. the point of return from b. Back at the start of the thr_create (like fork) function that called thr_create c. At the start of the function d. At the main() function in the specified in thr_create new a.out specifed in thr_create 5. An advantage of the use of kernel level threads over user level threads is that: a. thread creation is more b. there is less overhead efficient in thread scheduling c. the "one-blocks" "all-block" d. the problem with destructive problem is eliminated. competition for shared variables is automatically take care of. Computer Science 422/622 Quiz E Name__________________________ Consider the code shown below: int shared; int add() int sub() { { int local, i; int local, i; for (i = 0; i < 200000; i++) for (i = 0; i < 200000; i++) { { local = shared; local = shared; local += 1; local -= 1; shared = local; shared = local; } } } } 1. Suppose the a main program looks like: main() { add(); sub(); printf("%d \n", shared); } The output will be a. exactly 200000 b. exactly 0 c. varying between 0 and 200000 d. varying between -200000 and 200000 2. Now suppose the main is modified so that the two functions are run concurrently as threads. The output will be a. exactly 200000 b. exactly 0 c. varying between 0 and 200000 d. varying between -200000 and 200000 3. Answer T or F depending upon whether destructive behavior can or cannot ensue if one of the functions is preempted at the specified location: ____ a. IMMEDIATELY after executing local = shared; ____ b. IMMEDIATELY after executing local +-= 1; ____ c. IMMEDIATELY after executing shared = local; Computer Science 422/622 Quiz F Name _____________________ 1. Both processes have a "Process using Critical Section" flag. Before entering, a process loops until the other processes flag is clear and then sets its own flag. a. Not safe. b. Could cause starvation (livelock). c. Could cause deadlock. d. Causes strictly alternating access to critical section. e. Works correctly 2. Both processes have a "Process using Critical Section" flag. Before entering, a process sets its own flag and then loops until the other processes flag is clear. a. Not safe. b. Could cause starvation (livelock). c. Could cause deadlock. d. Causes strictly alternating access to critical section. e. Works correctly 3. In the deadlock susceptible version of the mutual exclusion algorithm, deadlock a. Is guaranteed to happen b. Deadlock can (but may not) occur even if only one process only when a process is preempted is trying to access the CS while inside the CS. c. Deadlock will occur every d. Deadlock can (but may not) occur time a process is preempted only when a process is preempted while trying to access the CS while trying to access the CS. 4. Which best characterizes the following attempt at the mutex problem THREAD0 THREAD1 RETRY: RETRY: t0using = 1; t1using = 1; if (t1using == 0) while (t0using == 1); { t0using = 1; crit-sec goto RETRY; } crit-sec a. Unsafe b. Deadlock prone c. Gives thread 0 priority d. Gives thread 1 priority over over thread 1 thread 0. 5. The order of setting and testing the "using" variable is the same is dekker's algorithm as it is in: a. the unsafe version b. the deadlock prone version Computer Science 422/622 Quiz G Name _____________________ 1. For Peterson's algorithm to function correctly, the setting of the "turn" and "p1using" variable a. Must occur in the order b. Must occur in the order p1using before turn. turn before p1using. c. May be done in either order without affecting correctness 2. A "wait" operation on a counting semaphore will cause a process to block.. a. If the value of the semaphore b. If the contents of the is > 0 at the time of the semaphores's wait queue wait. is empty c. If the value of the semaphore is zero at the time of the wait. 3. A "signal" operation on a counting semaphore will cause a the value of the semaphore to be incremented: a. If and only if the value is b. If and only if the semaphore's 0 at the time of the signal wait queue is empty at the time of the signal c. Either (a.) or (b.) is true. 4. Answer the following T or F: ___ a. A semaphore that has a non-0 value always has an empty suspended process queue. ___ b. A semaphore that has a non-empty suspended process queue always has a value of 0. Computer Science 422/622 Quiz H Name_____________________ Consider the following (correct) implementation of setlock: [0] CLI ;disable ints [1] RETRY: [2] CMPI LOCKVAL, 0 ;see if its 0 [3] JNZ RETRY ;if not, keep trying til it is. [4] TS LOCKVAL ;use the hardware to make sure. [5] JNZ RETRY ;start over if we got beat to the lock [6] RET 1. If statements [2] and [3] were removed which of the following BEST describes the result in a multiprocessor system: a. it would no longer work b. it would still work correctly correctly and it would and it would cause a performance cause a performance problem problem c. it still work correctly and improve performance 2. If statements [2] thru [5] were removed which of the following BEST describes the result in a uniprocessor system: a. it would no longer work b. it would still work correctly correctly and it would and it would cause a performance cause a performance problem problem c. it still work correctly and improve performance slightly 3. Suppose that the instruction [5.1] STI ;turn ints back on were inserted after statement [5] The result would be that a. The system would work b. The system would work worse better because the amount because multiple processes of disabled int code would might mistakenly be allowed be reduced. to hold the lock at the same time. c. The system would work worse d. The system would work worse if priority scheduling were because of both b. and c. in use because a low priority process might be preempted while holding the lock. 4. In a correct implementation of setlock() as given above the TS instruction will always find the lock value to be 0 (assuming (hohoho) no bugs it the OS). a. On the first try on both b. On the first try on single CPU single and multiple processor system but not necessarily systems. on multiple processor systems. c. On the first try on single CPU d. Never on either single or system but never mulitiple processor systems. on multiple processor systems. <<<<<<<<< OVER >>>>>>>>>>>>>>>>>>> 5. Suppose on a SINGLE PROCESSOR system the value of LOCKVAL was already 1 at the time the TS instruction was executed. The result would be a. A total system hang (crash) that b. The process trying to get the required a complete re-boot. lock would be slightly delayed until the lock holder released it. c. The process holding the lock and the process trying to get it would be deadlocked but all other processes would continue to run normally. Computer Science 422/622 Quiz I Name _____________________ 1. In releasing a TS lock a. INTS should be turned back b. INTS should be turned back on before setting the lock on AFTER setting to lock to to 0. to 0. c. Since rlse_lock() is d. Its not necessary to turn INTS non-blocking code it makes back on because they should not no difference. have been off in the first place. 2. A process that is holding a mutex semphore should never be: a. preempted b. suspended c. either preempted or d. neither preemption nor suspended suspension is prohibited 3. A process that is holding a TS lock should never be: a. preempted b. suspended c. either preempted or d. neither preemption nor suspended suspension is prohibited 4. Busy-waiting occurs while waiting for a. a semaphore held by another b. a TS lock held by another process process c. both sems and locks d. neither sems nor locks 5. In the producer consumer problem the consumer: a. waits on "items" and signals b. waits on "slots" and signals "items" after consuming. "items" after consuming. c. waits on "items" and signals d. waits on "slots" and signals "slots" after consuming. "slots" after consuming. Computer Science 422/622 Quiz J Name _____________________ 1. In the producer / consumer problem, the use of at least one mutex semaphore is necessary a. When there are multiple b. Whenever there are multiple producers and multiple consumers producers or muliple consumers. but not when there are multiple producers and a single consumer. c. Always d. Never 2. Deadlock can occur in a producer/consumer problem when the producers and the consumers use the same mutex semaphore and the consumer gets the waits in the wrong order: a. only when the buffer is full. b. only when the buffer is empty c. whenever the buffer is not d. whenever the buffer is not full empty 3. Deadlock can occur in a producer/consumer problem when the producers and the consumers use the same mutex semaphore and the producer gets the waits in the wrong order: a. only when the buffer is full. b. only when the buffer is empty c. whenever the buffer is not d. whenever the buffer is not full empty 4. When all consumers use "cmutex" and all producers use "pmutex" a. the system will fail because b. the correct order of the waits of lack of safe mutex is reversed c. deadlock is no longer possible d. the correct order of the waits regardless of the order of remains the same and deadlock the waits remains possible. 5. Suppose there are multiple producers and consumers and that each consumer and producer uses a private mutex. That is, consumer "j" uses "cmutex[j]" and producer "k" uses "pmutex[k]" a. the system will fail because b. the correct order of the waits of lack of safe mutex is reversed c. deadlock is no longer possible d. the correct order of the waits regardless of the order of remains the same and deadlock the waits remains possible. Computer Science 422/622 Quiz K Name _____________________ 1. We looked at a possible solution of the following form: writer() reader() { { wait(wsem); wait(wsem); -- write -- -- read -- signal(wsem); signal(wsem); } } the major problem with this solution is that: a. Reading and writing can b. Multiple writers can occur at the same time write at the same time c. Only one writer at a time d. Only one reader at may write a time may read 2. The second, more complex, solution for which we provided a semaphore based solution was: a. Reader priority solution b. Writer priority solution c. Strict FIFO fifo solution 3. In the second, more complex, solution, the writer code a. Is just like the writer b. Contains two semaphores code shown in (1) c. Contains a variable that d. Both c and d. counts the writers 4. In this more complex solution if a process is writing and multiple readers are waiting to read, a. All readers will be b. All readers will be blocked on blocked on wsem rmutex. c. All readers but one d. All readers but one will be blocked will be blocked on wsem on rmutex. 5. The reader exit code for this version looked like: wait(rmutex); rcount -= 1; signal(rmutex); if (rcount == 0) signal(wsem); The location of the signal(rmutex) is: a. Correct as it stands and moving b. Incorrect as it stands and it to just after the if stmt needs to be moved to just would break the code. after the if statement c. Works fine in either place Computer Science 422/622 Quiz L - Name ____________________ 1. In the condition variable based implementation of wait() a. the mutex is released before b. the mutex is released within calling pthread_cond_wait() pthread_cond_wait before blocking. c. the mutex is held while the thread is blocked. 2. In the condition variable based implementation of wait() a. the mutex must be reaquired b. The mutex is reaquired within by the caller of pthread_cond_wait pthread_cond_wait() after after the thread wakes up the thread wakes up c. There is no need to reaquire the mutex. 3. For pthread_mutex_lock() to work correctly, a. It is necessary that a TS b. Since pthread_mutex_lock() mechanism be used. is a system call, no TS is necessary 4. The condition variable based implementation of signal() looked like: pthread_mutex_lock(&s->mtx); s->value -= 1; pthread_cond_broadcast(&s->cv); pthread_mutex_unlock(&s->mtx); The location of the broadcast is: a. Correct as is and moving it b. Should be moved before s->value before s->value -=1 breaks the code. c. Works equally well in either place. Computer Science 422/622 Quiz M Name__________________________- 1. In class last time we organized the 4 mechanisms for process synchronization that we has studied as a hierarchy in which each mechanism was built using the mechanism below it in the hierarchy. Label the primitives (1), (2), (3) or (4) depending upon its place in the hierarchy (1) is lowest (depends on nothing) and (4) is highest (depends, indirectly at least, on all others). ______ a. Mutexes and CondVars ______ b. Message passing ______ c. Counting semaphores ______ d. TS locks 2. In the message passing system discussed in the last class the m_send() function: a. waited on items and b. waited on items and signalled slots signalled items c. waited on slots and d. waited on slots and signalled items signalled slots 3. In the message passing system discussed in the last class the counterpart m_recv() function would a. wait on items and b. wait on items and signal slots signal items c. wait on slots and d. wait on slots and signal items signal slots 4. In the 8 thread example in assignment 4 that was discussed last time in class a. each sender and receiver b. each sender thread sent to multiple thread used a single dedicated boxes but each receiver thread mailbox. read from a single box c. each receiver thread read from multiple boxes but each sender thread sent to a single dedicated box. Computer Science 422/622 Quiz N - Name ____________________ 1. The synchronization method used in unix pipes is what we described in class as: a. non-blocking sends and b. non-blocking sends and non-blocking receives blocking receives c. blocking sends and d. blocking sends and non-blocking receives blocking receives 2. The synchronization method indentified in class as "rendezvous" uses: a. non-blocking sends and b. non-blocking sends and non-blocking receives blocking receives c. blocking sends and d. blocking sends and non-blocking receives blocking receives 3. The buffer recycling problem a. goes away whenever single b. can't be eliminated in or double copy is used single copy but never occurs in double copy c. can be eliminated in single d. never occurs in double copy and double copy... but only and can be elilminated in via rendezvous synchronization single copy via rendezvous sync. 4. Which of the following strategies is most likely to lead to the need for "busy waiting" loops: a. blocking sends b. blocking receives. c. non-blocking sends d. non-blocking receives 5. Which of the following strategies is most likely to lead to the need for "busy waiting" loops: a. blocking sends b. blocking receives. c. non-blocking sends d. non-blocking receives Computer Science 422/622 Quiz O Name _____________________ 1. For each of the following resources identify the deadlock prevention mechanism that was described in class as being used in the "real world" ___ a. OS internal locks. 1. Declare resource sharable ___ b. Files and devices. 2. Use hierarchical allocation 3. Use preemption 4. Require simultaneous allocation 2. In order to guarantee that a deadlock over a resource can't occur it is NECESSARY to: a. Make sure that at least b. Make sure that all four one of the four conditions of the conditions can't can't hold. hold. c. Make sure that at least three of the four conditions can't hold. 3. We described 4 conditions that were associated with deadlock occurence. (To refresh your memory... one of them was "Hold and Wait".) In order to guarantee that a deadlock over a resource can't occur it is NECESSARY to: a. Make sure that at least b. Make sure that all four one of the four conditions of the conditions can't can't hold. hold. c. Make sure that at least three of the four conditions can't hold. 4. To break a two process deadlock it is NECESSARY to a. reboot the computer system b. kill both of the processes c. kill the process that caused d. kill either one of the two the deadlock deadlocked processes Computer Science 422/622 Quiz P Name _____________________ 1. Consider the graph shown below. It contains two 2-unit resources and three processes. Answer the following T or F: ____ a. The graph contains a cycle ____ b. The graph contains a knot ____ c. The system is deadlocked 4. In the deadlock detection algorithm, a system may contain a deadlock: a. even if all entries in the b. If a least one row in the requested table are 0. requested table has at least one non-zero entry c. If at least one row has d. If at least two rows have at all non-zero entries least on non-zero entry 5. Which of the following is invariant: a. avail[i] b. avail[i] + sum (alloc[i][j]) j c. avail[i] + sum(req[i][j]) d. avail[i] - sum (alloc[i][j]) j j Computer Science 422/622 Quiz Q - Name ________________________ 1. The proper time to run the deadlock detection algorithm is: a. Whenever a resource is b. Whenever a process is blocked allocated to a process because a resource is not available c. The algorithm must be run in both cases (a.) and (b.) 2. In the deadlock detection algorithm a process j is blocked if and only if: a. Requested[j][i] > 0 for b. Requested[j][i] > 0 for all i some i c. Requested[j][i] == 0 d. Requested[j][i] = 0 for some for all i. i 3. In the deadlock detection algorithm the resources of process j are released if a. Requested[j][i] >= avail[i] b. Requested[j][i] >= avail[i] for some i. for all i. c. Requested[j][i] <= avail[i] d. Requested[j][i] <= avail[i] for some i. for all i. 4. When the resources of process j were released what was added to avail[i]? a. Allocated[j][i] + b. Allocated[j][i] - Requested[j][i] Requested[j][i] c. Allocated[j][i] d. Requested[j][i] 5. The system was free of deadlock at the end of the procedure if a. At least one process was b. All processes were marked. marked. c. All processes were unmarked. Computer Science 422/622 Quiz R Name _____________________ 1. It is sometimes necessary to assign a new process to a partition that is far larger than it actually needs: a. In Fixed Partition systems b. In Variable Partition systems. c. In both types d. In neither type. 2. The number of partitions remains fixed after the system is started: a. In Fixed Partition systems b. In Variable Partition systems. c. In both types d. In neither type. 3. Recombining free blocks in a Variable Partition system is necessary a. Only during a partition b. Only when a partition is freed. allocation. c. Both a. and b. d. Only when a process terminates abnormally 4. In freeing a partition in a Variable Partition scheme of memory management, the number of elements in the FREE PARTITION LIST increases: a. Any time any recombining b. Never takes place. c. only when no recombining d. only when the newly freed is possible. partition recombines with BOTH the partition above it and below it 5. In freeing a partition in a variable partition scheme of memory management, the number of elements in the FREE PARTITION LIST decreases: a. Any time any recombining b. Never takes place. c. only when no recombining d. only when the newly freed is possible. partition recombines with BOTH the partition above it and below it Computer Science 422/622 Quiz S Name _____________________ Consider the following code fragment: Rel Loc Machine Code Assembler Code (IN HEX) (IN HEX) : : : : : : 000364 5010???? ST R1, X ;Store R1 in variable X. : : : : : : : : : 00046A 5820???? L R2, Z ;Load Z into R2. : : : : 0005F2 000B X DW 11 ;Define word variable x ; with init value 11 0005F4 ???? Y DW A(Z) ;int y; 0005F6 0063 Z DW 63 1. What value(s) (in hex) will the relocation table for this code contain? 2. What value will be inserted at by the assembler in place of the second batch of ????'s. (The L R2, X instruction) 3. Suppose this program is loaded into real memory at program base address 0xA800. What will be the actual value of the operand of the ST(ore) instruction (the 1st batch of ???'s) at the time the program actually begins execution. 4. Consider the following C variable declaration and initializations; [1] static int x = 100; [2] static int *y = &x; Which of the above will cause relocation table entry(ies) to be generated: a. [1] but not [2] b. [2] but not [1] c. Both [1] and [2] d. Neither 1 nor 2. 5. The relocation table is constructed: a. by the programmer b. by the compiler and linker when the a.out is built c. By the OS when the program is loaded into memory Computer Science 422/622 Quiz T Name _____________________ 1. Suppose bitmap based memory allocation is being used and that memory is being allocated in chunks that are even multiples of 256 bytes in size. If 1 MB = 2^20 Bytes of memory is being managed what is the size of the bitmap IN BYTES. a. 256 b. 512 c. 4096 d. None of the above 2. When base/bounds addressing is being used the base/bounds registers must be loaded: a. Only at the time the system b. Each time a new process is is booted. created. c. Each time a new process is d. Each time an instruction dispatched. is executed 3. When base/bounds addressing is being used, relocation fixups (of the type done on the previous quiz) are required: a. Only when the "a.out" is b. Whenever the program is moved initially loaded into memory after executing for a while.. c. Both a. and b. d. Neither a. nor b. Answer the following H, O, L, A depending upon whether the specified function is the responsibility of the Hardware, the OS, the Language compiler and/or Linker, or the Application itself in a system that uses base and bounds addressing. ___ 4. Loading the base and bounds registers. ___ 5. Adding the contents of the base register to each address presented by the application and comparing it to the contents of the bounds register. Computer Science 422/622 Quiz U Name _____________________ 1. The memory mgmt function in which segmentation has the biggest advantage over base and bounds addressing is: a. Protecting the OS from b. Support for controlled sharing user processes. among cooperating processes. c. Protecting independent d. No advantage in any of the user processes from areas. each other. 2. Which of the following is the MOST significant disadvantage of segmented memory management. a. Memory in OS Land is wasted b. Byte granular protection causes by segment tables. too many extra seg faults. c. Complexity makes it hard to d. Requires complex hardware support protect the OS from hackers. potentially increasing cost and decreasing speed. Answer the following H, O, L, A depending upon whether the specified function is the responsibility of the Hardware, the OS, the Language compiler and/or Linker, or the Application itself in a system that uses segmentation: ___ 3. Testing to make sure that the type of access being attempted in memory (read, write, or execute) is consistent with the attributes of the segment being referenced. ___ 4. Adding the contents of the segment base address to the offset generated by the application in order to get the real memory address. ___ 5. Constructing a segment table at the time a new process is created. Computer Science 422/622 Quiz W Name _____________________ Match each of the following descriptions with the correct settings of the P and A bits in a segmented memory management system: ____ 1. Segment has been stolen by OS and a. A = 0 P = 0 written out to disk b. A = 0 P = 1 ____ 2. Segment was dynamically allocated but later freed by the process c. P = 1 A = 0 ____ 3. Indicates a serious error in the d. P = 1 A = 1 OS 4. In demand segmentation which bit(s) are tested by the hardware each time memory is accessed: a. A b. P c. Both A and P d. Neither A nor P 5. In a demand segmentation system which of the following bits is SET by the segmentation hardware and periodically tested by the OS. a. A b. P c. R d. All of the above Computer Science 422/622 Quiz X Name _____________________ 1. The "fatal flaw" in demand segmentation that caused it to lose out to demand paging was: a. Poor capacity for b. Poor memory protection controlled sharing capability c. The difficulty in dealing d. All three were equally with variable size allocation important. of real memory and backing storage on disk 2. Suppose a paged memory system with pages having size 2048 bytes. How many address bits represent the offset in the page. 3. When a address is translated in a paging system, a. The offset is translated b. The page # is translated but the page # is not. but the offset is not. c. Both page # and offset are translated. 4. Suppose a computer system uses 4096 byte pages and virtual address with the value 0x006124 is generated. What physical address will this address be generated if the page table shown is used: 0x12b 0x345 0x12a 0x006 0x00b 0x001 0x234 PTBR -> 0x005 (Page Table Base Reg) 5. In a paged virtual memory system it is the case that when two independent processes share no memory at all. a. they cannot both legally b. the sets of real page frames access the same virtual underlying their virtual address address. spaces must be disjoint (non- intersecting). c. both a. and b. are true. d. neither a. nor b. is required. Computer Science 422/622 Quiz Y - Name ____________________ 1. The Least Recently Used (LRU) page stealing algorithm selects: a. A page only if it will b. The page last referenced never be referenced again. most distant in the past. c. The page that will next be d. The page with the least referenced most distant number of total references int the future. 2. The Optimal (OPT) page stealing algorithm selects: a. A page only if it will b. The page last referenced never be referenced again. most distant in the past. c. The page that will next be d. The page with the least referenced most distant number of total references int the future. 3. If a Java-like Virtual-machine O/S records EVERY reference made to memory, it would be theoretically possible to implement: a. both OPT and LRU b. neither OPT nor LRU c. LRU but not OPT d. OPT but not LRU 4. An O/S typically steals pages a. When the number of free b. When the number of free page page frames reaches 0. frames reaches a "low water mark". c. At fixed time intervals regardless of the number of free page frames 5. Suppose a paged memory system uses pages that are 1024 bytes in size and that a virtual address of 0xABCDE is referenced. a. What is the OFFSET (in hex). b. What is the Page Number (in hex). Computer Science 422/622 Quiz Z - Name ____________________ 1. In the implementation of Pseudo LRU that was discussed in class, the UIC associated with a page frame was set to 0 whenever a. The R (Referenced) bit b. The R bit was found to be 1 was found to be 0.. (referenced). (not referenced). 2. When a pseudo-LRU page replacement policy is in effect, global real memory overcommittment (==shortage) can be detected when: a. When the min value of b. When the max value of all UIC's is large. all UIC's is large. c. When the min value of d. When the max value of all UIC's is small. all UIC's is small. 3. The Least Recently Used (LRU) page stealing algorithm selects: a. A page only if it will b. The page last referenced never be referenced again. most distant in the past. c. The page that will next be d. The page with the least referenced most distant number of total references int the future. 4. The Pseudo LRU page stealing algorithm selects: a. A page only if it will b. The page with the least never be referenced again. number of total references c. The page with the lowest d. The page with the highest UIC value. UIC value. 5. Suppose X represents the number of real page frames available to a process and Y represents the rate at which the process generates page faults. The relationship between X and Y is closest to: a. Y = X * X b. Y = sqrt(X) c. Y = 1 / X d. Y = exp(X)