1
votes

Does each system call create a process? Are all functions (e.g. interrupts) of programs and operating systems executed in the form of processes? I feel that such a large number of process control blocks, a large number of process scheduling waste a lot of resources. Or, the kernel instruction of the system call is regarded as part of the current process.

2

2 Answers

1
votes

The short answer is - not exactly. But we have to agree on what we are going to call a "process". A process is more of an abstract idea, which encapsulates multiple instructions, each sequentially executed.

So let's start from the first question.

Does each system call create a process?

No. Each system call is the product of the currently running process, that tells the OS - "Hey OS, I need you to open this file for me, or read these here bits". In this case, the process is a bag of sequentially executed instructions, some are system calls, some are not.

Then we have.

Are all functions (e.g. interrupts) of programs and operating systems executed in the form of processes?

Well this kind of goes back to the first question. We are not considering that a system call (an operation that tell the OS to do something and works under very strict conditions) is a separate process. We will NOT see that system call execution to have its OWN process id (pid).

Then we have.

I feel that such a large number of process control blocks, a large number of process scheduling waste a lot of resources.

Well, I would say, do not underestimate your OS and the capabilities of your hardware. A modern processor with a modern OS on it, is VERY, VERY fast and more than capable of computing billions of instructions in seconds. We can't really imagine how fast that is. I wouldn't worry for optimizations on such a micro-level.


Okay, but let's dig deeper into this. What is a process exactly?

Informally, a process is a program in execution. The status of the current activity of a process is represented by a value, called the program counter, and the contents of the processor’s registers. The memory layout of a process is typically divided into multiple sections.

These sections include:

  1. Text section.
  2. Data section.
  3. Heap section.
  4. Stack section.

As a process executes, it changes state. The state of a process is defined in part by the current activity of that process. Each process is represented in the OS by a process control block (PCB), as you already mentioned.

So we can see that we treat a process as a very complicated structure that is MORE that just occupying CPU time. It has a state, storage, timing, and so on.

But because you are interested in system calls, then what are they?

For us, system calls provide an interface to the services made available by an OS. They are the way we tell the OS to do things FOR US. We know that systems execute thousands of system calls per second.

0
votes

No, they don't. The operating system uses software interrupt to execute the system call operation within the same process. You can imagine them as a function call but they are executed with kernel privileges.