ALL > Computer and Education > courses > university courses > undergraduate courses > Operating System > zstu-(2021-2022)-1 > student homework directories > 2019329621182刘辰萱 >
2019329621182刘辰萱homework2 Version 0
šŸ‘¤ Author: by rootfreanjacn 2021-09-21 17:27:24
Describe their relation and difference for process and program.

Differences:

  1. A program is a definite group ofĀ ordered operationsĀ that are to be performed. On the other hand, anĀ instanceĀ of a program being executed is a process.

  2. The nature of the program is passive as it does nothing until it gets executed whereas a process is dynamic or active in nature as it is an instance of executing program and perform the specific action.

  3. A program has aĀ longerĀ lifespan because it is stored in the memory until it is not manually deleted while a process has a shorter andĀ limitedĀ lifespan because it gets terminated after the completion of the task.

  4. The resource requirement is much higher in case of a process; it could need processing, memory, I/O resources for the successful execution. In contrast, a program just requires memory for storage.


Relation:

  1. There exist a many-to-one relationship between process and program, which means one program can invoke multiple processes, means that processes can be a part of the same program.


 

Why the status of process is divided into five states, not other numbers, such as 4,7? Ā describeĀ  the contents of process control block.

Five-State Process Model is an extension of theĀ Two-State Model. The two-stage model is efficient if all the processes in the Not-running state are ready for execution but this may not be true. Some processes in the Not-running state might be waiting for some event or I/O operation. Thus, the dispatcher cannot simply select the process from the front of the queue. The dispatcher would have to scan the queue to search for the process to execute. It degrades performance.
The best way to solveĀ this problem is to split the Not-running state into two states: Ready State and Blocked State.

Five-State Process Model States

  • Running:Ā The currently executing process.

  • Waiting:Ā Process waiting for some event such as completion of I/O operation, waiting for other processes, synchronization signal, etc.

  • Ready:Ā A process that is waiting to be executed.

  • New:Ā The process that is just being created. The Program Control Block is already being made but the program is not yet loaded in the main memory. The program remains in the new state until the long term scheduler moves the process to the ready state (main memory).

  • Terminated:Ā A process that is finished or aborted due to some reason.


Five-State Process Model State Transitions

  • New -> Ready: The long term scheduler picks up a new process from second memory and loads it into the main memory when there are sufficient resources available. The process is now in ready state, waiting for its execution.
    Ready -> Running:Ā The short term scheduler or the dispatcher moves one process from ready state to running state for execution.

  • Running -> Terminated:Ā The OS moves a process from running state to terminated state if the process finishes execution or if it aborts.

  • Running -> Ready:Ā This transition can occur when the process runs for a certain amount of time running without any interruption. For example, if we use round-robin to schedule processes, then the running process will move to the ready state after time quantum. Another example is if the priority of a process in the ready state is more than the priority of the currently running process, then OS may preempt the running process and move it to ready state.

  • Running -> Waiting:Ā A process is put in the waiting state if it must wait for some event. For example, the process may request some resources or memory which might not be available. The process may be waiting for an I/O operation or it may be waiting for some other process to finish before it can continue execution.

  • Waiting -> Ready:Ā A process moves from waiting state to ready state if the event the process has been waiting for, occurs. The process is now ready for execution.

Please login to reply. Login

Reversion History

Loading...
No reversions found.