Joke Collection Website - Mood Talk - What are the three main functions of process scheduling?
What are the three main functions of process scheduling?
Low-level scheduling: also known as process scheduling. Its main function is to allocate CPU to a process in the ready queue according to a certain algorithm. The program that performs the underlying scheduling function is called the process scheduler, which realizes the switching of CPU between processes. The running frequency of process scheduling is very high, and it often runs once every tens of milliseconds in a time-sharing system. Process scheduling is the most basic scheduling in the operating system. General operating system should have process scheduling, and its strategy directly affects the energy calculation of the whole system.
Intermediate scheduling: also known as exchange scheduling. In order to avoid too many processes stored in memory at the same time, sometimes it is necessary to move some processes from memory to external memory to reduce the number of multiprograms, so intermediate scheduling is established. Especially in the system using virtual storage technology or time-sharing system, the intermediate scheduling level is often added. Therefore, the role of intermediate scheduling is to switch some temporarily unavailable courses from memory to external memory and wait when the memory usage is tight. When there is enough free space in the memory in the future, the appropriate process will be replaced by another memory and wait for the process to be scheduled. The main purpose of introducing intermediate scheduling is to improve memory utilization and system throughput. It is actually an exchange function in memory management.
Let's talk about the strategy of process scheduling first (see resources):
First of all, how to ensure that the kernel scheduling process of the operating system can get the CPU to schedule the process at a certain time?
Usually we will find the answer at the software level. In fact, it is realized by the hardware processing mechanism of CPU. After executing each instruction cycle, the CPU scans the interrupt register inside the CPU to determine whether there is an interrupt, and if not, continues to execute the instruction. If yes, save the current CPU working environment, jump to the interrupt service list, the CPU executes the interrupt service program, and jump to the kernel scheduler after the interrupt is initiated (this is a kernel program, but it is shared by all processes, including the user process); At this point, the kernel scheduler occupies the CPU and schedules processes to determine the next process that will occupy the CPU.
Next, when do you need process scheduling?
Several situations mentioned in the textbook: 1 time slice arrives, that is, after the time slice allocated by each process is used up, it needs to jump to the scheduler; 2. When the currently running process occupying CPU puts forward I/O operation and initiates a system call to the kernel, it jumps to the scheduler after the system call is finished; My own idea: the currently running process should jump to the scheduler at the end of all kernel system calls, and decide the next process that can occupy CPU according to the current scheduling information. The system call I refer to also includes interrupt scheduling. But many books are not clear about the specific scheduling timing. I really don't know if they don't understand. I'm still too lazy to write it and tell us. In fact, except for most hardware interrupts that jump to the scheduler after being triggered, I think every time a clock interrupt occurs, I have to jump to the scheduler. (When entering the clock interrupt sequence, update the scheduling information of all processes in the process table and process the process queue), process the updated process information and decide which process to schedule. In general textbooks, the physical processing mechanism of hardware and the scheduling processing mechanism of software are separated, which is not conducive to our understanding. It is best to combine the two to understand the working mechanism of process scheduling. At present, the problem to be solved is: when do you need the kernel scheduler to occupy CPU for scheduling? As for the scheduling algorithm, that is something to be considered at the logical level.
In fact, after reading so much, I also have some ideas about the small paper, because the direction is to apply embedded system control to electronic power supply circuits. This application has some special requirements for the performance of embedded operating system: first, it should be small and fast; The kernel should be small, the process scheduling should realize preemptive task scheduling, and the scheduling switch should be fast. Its process scheduling is different from the general operating system because of their different requirements. Embedded system usually requires real-time, strictly speaking, the control system on the circuit should be hard real-time, unlike the general operating system, which is not real-time. Or soft real-time. This is different from their real-time requirements. So I tentatively set up a topic "Comparative analysis of process scheduling between embedded system and general system, and put forward a scheduling strategy for embedded real-time system controlled by specific circuit". I think I will get these materials ready, analyze and compare them from tomorrow, and get a small paper, otherwise I will die for it.
Operating system-process scheduling
[color = silver] [/color] [color = gray] [/color] [color = magenta] [/color] [color = blue] [/color] [color = light green] [/color] [color = lime] [/color] [size = 4] [
Content:
1: Design necessary data structures such as fast process control and process queue structure (including: ready queue, waiting queue and running queue).
2. Simulate the function of operating system process scheduling, and write process scheduler, simulate processor scheduler, process waiting function and process wake-up function.
3. Write user programs and create 6 user processes.
Design method of process scheduling
1。 data structure
(1) Priority and Time Slice Design
◆ When the process is waiting to give up the CPU, the priority is set to 1 (high priority).
◆ When the process abandons the CPU due to time slice, the priority is set to 0 (low priority).
◆ Priority 1 corresponding time slice 4; Priority 0 corresponds to time slice 10.
(2) the content of the process control block (PCB)
Process ID 3-9
Process priority 0. 1
Process priority 0. 1
Process waiting time 20
Link pointer
2. Program algorithm
(1)PCB structure, variables and main program
Structural printed circuit board
{
int pname
int pri
Int runtime;
Waiting;
struct PCB * next
}
Polychlorinated biphenyl [7];
Struct PCB * is running, ready, waiting;
int sin = 0;
Master ()
{Create PCB [3]-PCB [9] and insert it into the ready queue; /* pname is 3-9 respectively,
Priority =0, running time = 10, waiting time =0 */
for(; ; )/* System program to complete initialization and processor allocation */
{ cast { SIG = 0:swtch;
Sig= 1: waiter;
SIG = 3:proc 3;
SIG = 4:proc 4;
SIG = 5:proc 5;
SIG = 6:proc 6;
SIG = 7:proc 7;
SIG = 8:proc 8;
SIG = 9:proc 9; }
}
}
(2) Process scheduler
Switch ()
{
while(ready = = NULL)wake up();
Move the first PCB out of the ready queue;
Sending a running pointer;
If pri= 1 and Runtime = 4, otherwise Runtime =10;
Send running→pname to sig.
}
(3) Process waiting function
Wait ()
{Insert the running process into the waiting queue and set the priority number to1;
SIG = 0;
}
(4) process wake-up function
Wake up ()
{
Subtract1from the waiting time of all PCBs in the waiting queue;
Remove all PCBs with waittime=0 from the waiting queue.
Insert in front of the first PCB with priority 0 in the ready queue.
}[/b][/font][/size]
- Previous article:Talk about taking notes
- Next article:Tell the world well.
- Related articles
- Sentences that make people want to cry _ sad sentences
- What would you do if your 0/2-year-old son stole mommy's underwear?
- What's the name of that eulogy for the dead? It seems to be an accusation or something.
- The sad sentence about love wipes away the tears on your face, but it can't take away the feeling of pain in your heart.
- I have 100 square meter frontage on the upper and lower floors. Let's talk about what business I can do on the edge of the community first.
- Talking about bereavement
- A statement about fairy tales
- The Origin of Five Elements Theory
- Sentences that work together
- How to raise Shiba Inu?