To manage CPUs, first use CPU ...
How the CPU works
What happens after the CPU is power-up? automatic pick-and-run
- How does the CPU work?
- How does the CPU manage?
The most intuitive way to manage CPUs
Set the PC initial value is done!
See if there's a problem with that? Ask questions
How to solve?
Now it's like this.
Multi-channel program, alternating execution, good thing Ah!
|
Single-Channel program |
Multi-Channel Program |
CPU Utilization |
40/80=50% |
40/45=89% |
DEV1 Utilization |
15/80=18.75% |
15/45=33% |
DEV2 Utilization |
25/80=31.25% |
25/45=56% |
A CPU facing multiple programs?
Executes multiple programs alternately on a CPU: concurrency
How do you do that?
Is it OK to modify the Register PC?
Run the program and the static program is not the same ...
Introducing the concept of "process"
Run the program and static program is not the same!
- Need to describe these different ... (these are not the same as the extension of the process concept)
- Program + all of these are not the same as a concept (all the different are shown in the PCB ...)
A process is a program in progress (execution)
- The process has started, has ended, the program has not
- The process will walk, stop, stop, no meaning to the program.
- The process needs to record the AX,BX,..., the program does not
- ............
Multi-process image multiple Processes ... Images for multiple processes using CPUs
How do I use the CPU?
How to make full use of CPU?
- Start multiple programs, alternate execution
The program that starts is the process, so it's a process that pushes
- The operating system only needs to record these processes and move them in a reasonable order ( allocating resources and scheduling ).
- This is the multi-process image ...
Multi-process image from start to end of shutdown
Fork () in main creates a 1th process
- Init executes the shell (Windows desktop)
if (!fork ()) {init ();}
Shell and start other processes
int main (int argc, char * argv[])
{while (1) {scanf ("%s", cmd);
if (!fork ()) {exec (cmd);} wait (); } }
a command starts a process, returns the shell and starts another process ...
Multi-process Images: How are multiple processes organized?
There is a process in the execution
There are processes waiting to be executed
There are some processes waiting for an event
Organization of multiple processes: pcb+ status + queue
Run → wait; Run → Ready; Ready → run ...
- The graph is called the process state diagram
- It can give a clear description of the process life time.
- It is a window to understand the management of operating system processes
Multi-process images: how do multiple processes alternate?
Start disk read and write;
pcur.state = ' W ';
Put the pcur into the diskwaitqueue;
Schedule ();
Schedule ()
{
Pnew = getNext(readyqueue);
switch_to (pcur,pnew);
}
Alternating three parts: queue operation + Dispatch + Switchover
Is the process of scheduling, a very profound topic
Fifo?
FIFO is obviously a fair strategy
FIFO obviously does not consider the difference between the tasks that the process executes
Priority?
What is the priority setting? May make some process hungry
Switch_to (pcur,pnew) {
PCUR.AX = CPU.AX;
PCUR.BX = CPU.BX;
...
PCur.cs = CPU.cs;
PCUR.RETPC = cpu.pc;
CPU.AX = PNEW.AX;
CPU.BX = PNEW.BX;
...
CPU.cs = PNew.cs;
cpu.retpc = pnew.pc; }
Multi-process Image: How does multi-process affect?
The following problem occurs when multiple processes are present in memory at the same time
Workaround: Limit read and write to address 100
Multi-process address space separation: The main content of memory management
Process Execution 100 ...
- The mapping table for process 1 restricts access to the scope of process 1
- Process 1 does not access the content of other processes at all
- Memory Management ...
Process-driven memory usage
Why is process management associated with memory management forming a multi-process image?
Multi-process Images: how do multiple processes work together?
Think about the process of printing a job
- Application Submission Print Task
- The print task is placed in the print queue
- The print process pulls the task out of the queue
- Print process controls Printer printing
From paper to reality: producer − Consumer example
Two collaborative processes are to be modified counter
The core lies in the process synchronization (reasonable propulsion sequence)
Block other processes from accessing counter when writing counter
How to form a multi-process image?
- Read and write PCB, themost important structure in the OS, throughout always
- To operate the register to complete the switchover
- To write the scheduler
- To have process synchronization and cooperation
- To have address mappings
[No000038] Operating system operating SYSTEMS-CPU