Lesson 3 Process Management
Lesson 3 Process Management
3. For the processing model of this following figure, briefly define each state.
Answer:
1) New: The process has not yet been loaded into main memory.
2) Ready: the process is now prepared to execute when given the opportunity.
3) Running: the process is currently being executed.
4) Blocked: Process that is waiting for some event to occur.
5) Exit: Process is released from main memory because it has halted or aborted.
4. What does it mean to preempt a process?
Answer:
To maximize the number of processes in the system, we swap a process from the ready state to
the ready suspend state (i.e. give its memory to another process)
To take a resource away from a process. One such resource is the CPU, and in fact preempt often
means to move a process from RUNNING state to READY state. The process involuntarily gives up the CPU.
8. List reasons why a mode switch between threads may be cheaper than a mode switch between
processes.
Answer:
1.reason – the control blocks for processes are larger
than for threads (hold more state information), so the
amount of information to move during the thread switching
is less than for process context switching
9. Give four general examples of the use of threads in a single-user multiprocessing system.
Answer:
Foreground and background work: For example, in a spreadsheet program, one thread could
display menus and read user input, while another thread executes user commands and updates the
spreadsheet. This arrangement often increases the perceived speed of the application by allowing the program
to prompt for the next command before the previous command is complete.
Asynchronous processing: Asynchronous elements in the program can be implemented as threads. For
example, as a protection against power failure, one can design a word processor to write its random access
memory (RAM) buffer to disk once every minute. A thread can be created whose sole job is periodic backup
and that schedules itself directly with the OS; there is no need for fancy code in the main program to provide
for time checks or to coordinate input and output.
Speed of execution: A multithreaded process can compute one batch of data while reading the next batch
from a device. On a multiprocessor system, multiple threads from the same process may be able to execute
simultaneously. Thus, even though one thread may be blocked for an I/O operation to read in a batch of data,
another thread may be executing.
Modular program structure: Programs that involve a variety of activities or a variety of sources and
destinations of input and output may be easier to design and implement using threads.
10. What resources are typically shared by all of the threads of a process?
Answer:
All of the threads of a process share the state and resources of that process.
They reside in the same address space and have access to the same data. When one thread alters an item of
data in memory, other threads see the results if and when they access that item. If one thread opens a file with
read privileges, other threads in the same process can also read from that file.
Answer:
One thread be blocked, whole process be blocked.
But many system calls are blocking.
A multi-threaded application cannot take advantage of multiprocessing.
Mutual exclusion.
Only one process may use a resource at a time.
Hold and wait.
A process may hold allocated resources while awaiting assignment of others.
No preemption.
No resource can be forcibly removed from a process holding it
The above three conditions, plus: Circular wait. A closed chain of processes exists,
such that each process holds at least one resource needed by the next process in the
chain.s
15. What is the difference among deadlock avoidance, detection, and prevention?
Answer:
Deadlock prevention constrains resource requests to prevent at least one of the our conditions of
deadlock; this is either done indirectly, by preventing one of the three necessary policy conditions
(mutual exclusion, hold and wait, no preemption), or directly, by preventing circular wait.