Kernel-level thread, user-level thread and time round-robin scheduling algorithm

Kernel-level thread, user-level thread and time round-robin scheduling algorithm

An operating system supports kernel-level threads, and the processor adopts the time slice round-robin scheduling algorithm. The system currently has process A and process B, and process A has 2 threads, and process B has 100 threads, then the execution time of process A should generally be the execution time of process B ( D ).
A.50 times
B.100 times
C.1 times
D.1/50

A system does not support kernel-level threads but supports user-level threads, and the processor adopts the time slice round-robin scheduling algorithm. The system currently has process A and process B, and process A has 1 thread and process B has 100 threads, then the execution time of process A should generally be the execution time of process B ( B ).
A.50 times
B.1 times
C.100 times
D.1/100

To understand the above two questions, first briefly look at these important concepts (more details will not be repeated, other blogs are more clear):

  1. User-level thread : User-level thread, to put it bluntly, is the thread supported by the application program. All the work related to the thread is done by the application program, and the kernel is not aware of the existence of the thread ! User-level threads are invisible to the operating system and therefore cannot be scheduled to the kernel. The threads of each process are only visible in user space.
  2. Kernel-level threads : All management of threads is controlled by the kernel, threads are visible to the kernel, and a user thread is mapped to a kernel thread.
  3. Time round-robin scheduling algorithm (violent understanding) : 5 monks (processes) line up to eat rice, and the food intake of 5 people is 2, 3, 1, 4, 5 (the time required for the process to finish execution), and the rice spoon can be eaten every time 3 Meals (time slice), it is stipulated that each monk is only given one spoonful, which can be more or less. If it is enough, it will go (the process is completed and ended), if it is not enough, it will be queued at the end of the queue and wait for a spoonful. Here, each spoon can make 3 meals, which is the prescribed time slice, and the process of queuing up and down is the time rotation algorithm.

Topic analysis : In the above two questions, process A has 2 threads, and process B has 100 threads.
For the case of supporting kernel-level processes: the kernel can see the threads in the process, and the time slice is the same, so 2/ 100=1/50, choose D;
for the case of supporting user-level threads: the kernel can only see the process, so it is A process VS B process, 1V1, so choose B

It's just my own simple understanding, welcome to add in the comment area, if there is any mistake, welcome to correct me!

Guess you like

Origin blog.csdn.net/weixin_45913922/article/details/116073235