Operating System notes six (thread management and scheduling)

1. Why propose a thread
in order to allow concurrently executed between entities
share the same physical address space between
this entity it is the thread

2. Thread (thread) definition: a process execution flow among
processes and threads composed by the resource management
process = + threads shared resource
threads advantage is made of threads of the
disadvantages is the thread: a thread collapse, will lead the process to which they belong all threads crash

Comparison of processes and threads
1. The process is a resource allocation unit, the thread is CPU scheduling unit
2. The process has a complete resource platform, and the thread only exclusive essential resource
3. Thread equally ready, blocked, perform three state
4. thread can reduce the time and space overhead concurrent execution

3. Thread the realization of
user threads: OS can not see the
OS may not participate in scheduling user threads,
kernel threads: OS can see the
disadvantage of the user thread: 1. If a thread is blocked initiated system call, the whole process is waiting (because OS thread can not see, can only understand the process, so the whole process will be blocked) 2. when a thread is running, unless he took the initiative to hand over the right to use the CPU, among other threads or processes where he will not be able to perform
user and more thread time may be slower

Kernel threads: a thread mechanism implemented in the OS kernel, created to complete the internal thread, termination and management
in a process, if a kernel thread initiated system call blocking, and does not affect other kernel threads the run
time slice allocated to the thread, multi-thread CPU time more

Lightweight processes: OS control user threads

7-11 context (process) switch
stops the currently running process, and other processes scheduling
context register contents are required to be stored, CPU status, etc.

Process control - waiting and terminate the process
wait () system call is used to wait for the end of the parent process child process, as to why you want to wait for the end of it, that is
when the child process exit () after notification by the parent OS, to help the child process is complete resource release (especially PCB)

The processor CPU scheduling
can not be seized: scheduler must wait for the end of the event
can seize: scheduler executed after interrupts are
currently running program can be swapped out
the current process to switch from running to ready, or wait for a process to switch from ready

8.2 Principle scheduling
execution model: Burst program in the CPU and I / O alternately
when the switching / O busy when a program to other processes running I

FCFS FCFS
advantages: Simple
disadvantages: the average waiting time fluctuations
less time spent at the back of the task may take a long time for the task
may cause overlap between the handle I / O and CPU

SPN / SRT short process priority
to select the next shortest process (short task priority) in accordance with the predicted time to complete the task team

It may be preemptive or non-preemptive: preemptible: shortest remaining time to
the average waiting time is the shortest
continuous short length makes the task flow task starvation
short length of any available task task CPU time will increase the average latency

round robin: turns of CPU to perform
context switching overhead control within 1%

Priority decrease CPU-intensive tasks quickly (large computation)
the I / O-intensive tasks remain in the high-priority (high interactivity)

8.5 real-time scheduling
defined: to ensure that certain tasks are completed within the stipulated time
hard real-time systems: the need to complete important tasks within the guaranteed time, must complete the
soft real-time systems: requirements to complete as much as possible, not necessarily

RM (rate monotonic) rate monotonic scheduling: by period prioritize
EDF (earliest deadline first): The sooner the earliest deadline scheduling deadline higher priority

Over 8.6 scheduling and priority inversion processor
CPU scheduling more complex multi-processor: Load sharing
symmetric multi-processor: each processor runs its own scheduler, and the scheduler need to synchronize

Published 44 original articles · won praise 9 · views 3394

Guess you like

Origin blog.csdn.net/puying1/article/details/96726551