501 I Street SW
Washington, DC 20024
Tel: (202) 488-8162 Fax: (202) 488-8093
Student Name: ___________________________
Midterm Exam: August 2000
Course: COSC 513 Operating Systems Student ID: ______________________
Instructor: Prof. M. Anvari
What is User-Visible Registers? And what does it contains?
Types of register that are typically available to all programs and
Contains Data, Address, and condition code.
What is Interrupt and why do the Operating Systems provide interrupt-handling
Interrupts are provided as a way to improve processing efficiency.
Handlers are responsible for managing the Interrupts.
What are the typical services provided by the operating systems?
Access to I/O devices
Controlled Access to files
Error detection and responses
Page 1 of 4__COSC513 _ Midterm Exam _ Southeastern University, Washington DC _ Aug 2000___ Prof. M Anvari
What are the Examples of Control & Status Registers?
Program Counter (PC)
Contains the address of the next instruction to be fetched
Instruction Register (IR)
Contains the instruction most recently fetched
Program Status Word (PSW)
A register or group of registers containing:
Condition codes and status info bits
Interrupt enable/disable bit
Supervisor (OS)/user mode bit
What are the necessary and sufficient conditions for deadlock? (Briefly explain each one)
1: Mutual exclusion
Only one process may use a resource at a time
A process may hold allocated resources while awaiting assignment of others
3: No preemption
No resource can be forcibly removed from a process holding it
A closed chain of processes exists, such that each process holds at least one resource
needed by the next process in the chain
In few words define Multiprogramming, Multiprocessing, Multithreading and
Multiprogramming = Multitasking.
Multiprocessing = Parallel Processing
Multithreading = Ability to support multiple threads of execution within a single process and
Not single thread of execution per process.
. Explain the difference between a process and a thread.
Process is Unit of Resource Ownership or Task
Thread is unit of dispatching or lightweight Process
Thread has no suspend state
Page 2 of 4__COSC513 _ Midterm Exam _ Southeastern University, Washington DC _ Aug 2000___ Prof. M Anvari
What is Cache Memory?
Small cache of expensive but very fast memory interacting with slower but much larger memory
Invisible to OS and user programs but interact with other memory management hardware
Processor first checks if word referenced to is in cache
If not found in cache, a block of memory containing the word is moved to the cache
. What is a problem with the following Algorithm?
Pi is busy waiting if Pj is in CS: mutual exclusion is satisfied repeat
Progress requirement is not satisfied since it requires strict alternation
of CSs turn:=j;
Ex: P0 has a large RS and P1 has a small RS. If turn=0, P0 enter its CS RS
and then its long RS (turn=1). P1 enter its CS and then its RS (turn=0) forever
and tries again to enter its CS: request refused! He has to wait that P0
leaves its RS.
What are the benefits of Threads vs Processes? And how does it work on a SMP
Takes less time to create a new thread than a process
Less time to terminate a thread than a process
Less time to switch between two threads within the same process
Consider an application that consists of several independent parts that do not need to run in
Each part can be implemented as a thread
Whenever one thread is blocked waiting for an I/O, execution could possibly switch to another
thread of the same application (instead of switching to another process)
Since threads within the same process share memory and files, they can communicate with each
other without invoking the kernel
Therefore necessary to synchronize the activities of various threads so that they do not obtain
inconsistent views of the data (chap 5)
On a SMP machine: multiple threads can possibly be executing simultaneously on different
Page 3 of 4__COSC513 _ Midterm Exam _ Southeastern University, Washington DC _ Aug 2000___ Prof. M Anvari
. What are Semaphores? And what are they used for?
Synchronization tool (provided by the OS) that do not require busy waiting
A semaphore S is an integer variable that, apart from initialization, can only be accessed through
2 atomic and mutally exclusive operations:
To avoid busy waiting: when a process has to wait, it will be put in a blocked queue of processes
waiting for the same event
. What are the Types of solutions for the CS Problems?
Algorithms who’s correctness does not rely on any other assumptions (see framework)
Rely on some special machine instructions
Operation System solutions
Provide some functions and data structures to the programmer
What are the Requirements for a valid solution to the critical section problem?
At any time, at most one process can be in its critical section (CS)
If no process is executing in its CS while some processes wish to enter, only processes that are
not in their RS can participate in the decision of which will enter its CS next. This selection
cannot be postponed indefinitely
After a process has made a request to enter it’s CS, there is a bound on the number of times that
the other processes are allowed to enter their CS
Otherwise the process will suffer from starvation
How do you define the User-Level Threads (ULT)? And what are the Kernel activities
The kernel is not aware of the existence of threads
All thread management is done by the application by using a thread library
Thread switching does not require kernel mode privileges (no mode switch)
Scheduling is application specific
Kernel activity for ULTs
The kernel is not aware of thread activity but it is still managing process activity
When a thread makes a system call, the whole process will be blocked
but for the thread library that thread is still in the running state
So thread states are independent of process states
Page 4 of 4__COSC513 _ Midterm Exam _ Southeastern University, Washington DC _ Aug 2000___ Prof. M Anvari