Operating Systems of Mobile Devices (OSMZ)

Week II. (15.2.-19.2.2021)

The topic of this (second) week is the concept of processes, their life cycle and context switching.

Process is the name for a running instance of a computer program. It contains not only the code of the executed program but also all its dynamic data. As a result, one application (program) can run on one computer in the form of one or more processes with different data. On Linux, the process is defined by the task_struct structure, which can be found in the kernel source files in include/linux/sched.h . In its current form, it is a rather complex structure, its basic and annotated form from the kernel version 0.12 can be read in the book A Heavily Commented Linux Kernel Source Code on page 212. Each process is represented by this structure, more generally called a PCB (Process control block), the maximum number of which can be fixed or changed dynamically (depending on the specific OS). Another illustration of the PCB, specifically the Minix operating system, can be found in the presentation on page 49.

During the run of the operating system, multitasking quickly switches processes, processes are started and stopped, waiting for inputs, etc. The process life cycle can be illustrated by a diagram of state transitions (presentation page 46 and animation). For several concurrent processes, the runtime is governed by rules such as time quantum, priority, or hardware interrupts (this will be described next week in connection with task schedulers). Switching between processes is called switching / changing context. This saves the current CPU state corresponding to the currently running process and restores the CPU state to continue the second process. An example with a description of the actions performed during the time when switching takes place can be found in the presentation. There you will find an example of context switching on the AVR architecture (used for example on Arduino boards) and the FreeRTOS operating system. In Linux, the implementation is more complex and thus less suitable for demonstration and explanation.

Later, we will get acquainted with context switching in practice, where we will implement our own thread scheduler and we will have to deal with thread context switching within one running user process.



Andrew S. Tanenbaum - Modern operating systems. 4th edition:

  • Processes (pp. 39-41)
  • Chapter Processes and Threads (pp. 85-106)


You can read a more detailed description of the processes related to the planners. Another description of the processes can be found in the Linux Documentation Project. Linux has a wide range of monitoring and debugging utilities, summarized at this page. The site also contains a very illustrative diagram with the names of the relevant applications.


After reading the above texts, you should be able to answer following questions from the topics for the exam, specifically:

  • Describe the process and its life cycle.
  • What is a process control block (PCB), what is it used for and what records must it contain.
  • Describe the context switching.
  • Threads vs. processes, characteristics - common and different features, implementation in OS.