- The relations and differences between process and program.
To describe the relations and differences between process and program, I would like to quote the analogy that their relationship is like the relationship between performance and scr ipt.
- Just like performance and scr ipt, the process is dynamic, while the program is static.
- As the previous aspect said, a process exists temporarily, while a program could last for a long time. In more professional exp ression, a process have a certain life cycle, while a separate program is incapable to be running.
- Like one scr ipt could be performed at more than one stage in a moment, one program can correspond to multiple processes. However, one process can only correspond to one program.
- After all, the composition of process and program is different. From a static point of view, the process consists of program, data and process control block. A program is an ordered set of instructions.
- The reason why the status of process is divided into exactly 5 states.
First of all, the 5 states mentioned in the question are: new, running, waiting, ready, terminated.
It's obvious that state new means the creating of a process, state running means that the instructions are being currently executed, and state terminated means the execution has been finished.
The problem is that only one process could have its instructions executed on a single processor at any instant. Here comes state ready, which means the process is waiting to be assigned to a processor.
Besides, the process might have to wait for some particular events to occur. That lead to state waiting.
That's generally how the 5 states are divided.
- The contents of process control block.
- Process status, which includes new, ready, running, waiting, stopping, etc.
- Program counter, which indicates the address of the next instruction to be executed by the process.
- CPU registers, which may include accumulators, index registers, stack pointers, general registers, and other condition code information registers.
- CPU-scheduling information,which includes process priority, pointer of scheduling queue and other scheduling parameters.
- Memory-management information, which could include the value of base address and boundary register, page table or segment table.
- Accounting information, which includes CPU time, actual usage time, time period, accounting data, number of jobs or processes, etc.
- I/O status information, which includes the list of I/O devices assigned to the process, the list of open files, etc.