2.2.8. Rehearsal

At this point, you should understand how multiple processes can run in parallel on a computer with multiple processors, and how an illusion of multiple processes running in parallel can be provided even when the number of processes is higher than the number of processors. You should be able to recognize important parts of process context and explain how efficient context switching can be done with each part of the process context.

You should see why it can be useful to split an activity of a process into multiple threads. You should understand why and which parts of the entire context remain shared parts of the process context and which parts become private parts of the thread context.

You should be able to design meaningful rules telling when to switch a context and what context to switch to, related to both the architecture of the operating system and the requirements of the applications. You should be able to explain the working of common scheduling algorithms in the light of these rules.

Questions. 

  1. Explain how multiple processes can run concurrently on a single processor hardware.

  2. Explain what is a thread and what is the relationship between threads and processes.

  3. Explain what happens when the thread context is switched.

  4. Explain what happens when the process context is switched.

  5. Using a step by step description of a context switch, show how an implementation of threads in the user space and an implementation of threads in the kernel space differ in the way the context is switched.

    Na popisu přepnutí kontextu krok po kroku ukažte, jak se implementace vláken v uživatelském prostoru a implementace vláken v prostoru jádra liší ve způsobu přepínání kontextu.

  6. Explain how the requirements of interactive and batch processes on the process scheduling can contradict each other.

  7. List the typical requirements of an interactive process on the process scheduling.

  8. List the typical requirements of a batch process on the process scheduling.

  9. List the typical requirements of a realtime process on the process scheduling.

  10. Explain the difference between soft and hard realtime scheduling requirements.

  11. Define typical phases of a process lifecycle and draw a transition diagram explaining when and how a process passes from one phase to another.

  12. Explain cooperative context switching and its advantages.

  13. Explain preemptive context switching and its advantages.

  14. Explain the round robin scheduling algorithm by outlining the code of a function GetProcessToRun that will return a process to be scheduled and a time after which another process should be scheduled.

  15. Explain the simple priority scheduling algorithm with static priorities by outlining the code of a function GetProcessToRun that will return a process to be scheduled and a time after which another process should be scheduled.

  16. Explain the simple priority scheduling algorithm with dynamically adjusted priorities by outlining the code of a function GetProcessToRun that will return a process to be scheduled and a time after which another process should be scheduled.

  17. Explain the earliest deadline first scheduling algorithm by outlining the code of a function GetProcessToRun that will return a process to be scheduled and a time after which another process should be scheduled.

  18. Explain the function of the Solaris process scheduler by describing how the algorithm decides what process to run and for how long.

  19. Explain the function of the Linux process scheduler by describing how the algorithm decides what process to run and for how long.

  20. Explain the function of the Windows process scheduler by describing how the algorithm decides what process to run and for how long.

  21. Define processor affinity and explain how a scheduler observes it.

  22. Propose an interface through which a thread can start another thread and wait for termination of another thread, including passing the initial arguments and the termination result of the thread.

Exercises. 

  1. Design a process scheduler that would support coexistence of batch, realtime and interactive processes. Describe how the processess communicate their scheduling requirements to the scheduler and what data structures the scheduler keeps. Describe the algorithm that uses these requirements and data structures to decide what process to run and for how long and analyze the time complexity of the algorithm.