processes, threads

Let's start with what threads are. Wikipedia defines a thread as:

In computer science, a thread of execution is the smallest sequence of programmed instructions that can be managed independently by a scheduler, which is typically a part of the operating system.

The most important thing here is that we recognize a thread is defined in the context of a scheduler which is the part of an operating system's kernel. What does a kernel do? Manage processes. A process is the instantiation of software or a program, which is stored in the HDD. A software aka program becomes a process when its instantiated —loaded into the RAM aka memory. An OS runs multiple programs (or manage process) and its up to kernel to decide which process and priority and how much time it gets in the CPU.

OK. From the above paragraph it becomes clear that a kernel manages process. But the Wikipedia definition says the smallest sequence of programmed instructions that can be managed by a scheduler is a thread. The complete definition from wikipedia includes his line too:

In many cases, a thread is a component of a process.

Also note the word sequence. A sequence of instructions. Each thread can be conceptualized accurately as a conveyor belt which feeds instructions to the CPU

Now, is a good time to look at the diagram provided in wikipedia:

1741032646.png

Note:

  1. The program is first stored in the HDD, and is conceptualized as a series of instructions.
  2. The program gets instantiated —loaded into RAM/memory as a process.
  3. The RAM is conceptualized as a containing multiple processes. But what the scheduler manages are not the process but the threads. Here we see that a process can split itself into multiple threads. For now I think it depends on the programming language used and the programmer who made the software.

Comments