Processes and Threads in operating system

Processes and Threads in operating system


Hello, and welcome to this video and processes and threads in operating system. Let us start with an introduction to processes and threads. First, an introduction to processes. Now, in computer science a process is a running program. This means that a software program just stored on the disk is not a process. instead, a software program loaded into the main memory and executing is a process. A process includes the program code and its current state. There can be multiple process states. The process state can be Created, which means that that it is loaded from the disk to the main memory. Another process state is Waiting. This means that the process is waiting for the operating system’s scheduler software to load the process into the processor. The third process state is Running. This means that the processor is executing the process’s instructions. Another process state is Terminated. This means that the process is complete and ready to be unloaded from the main memory. Process state can also be Blocked, if it is waiting for user input. A single process consists of one or more threads. We will learn about threads in just a moment. Multitasking. This means that a single CPU can run multiple processes at the same time. Multitasking allows the multiple processes to share resources like processor time, memory, physical disks and peripherals like displays or printers. Let us see an introduction to threads. A thread is an independent sequence of instructions. The difference between process and thread is that the thread is created by a process. Also, a thread is a subset of the process. Now, multiple threads within a process share the process instructions, the process variables and the process state. Now, let us look at multi-threading. A single CPU can run multiple threads concurrently by context switching between them. Since this happens very fast, the user feels that multiple threads are running simultaneously. In reality, only one thread is actually running at any one point in time. If the CPU has multiple cores like dual-core, quad-core and so on or multiple processors, multiple threads can actually be run in parallel on different cores, or different processors. Let us look at multi-threading advantages and disadvantages. One advantage of multi-threading is responsiveness to user input. The process can assign long tasks like printing to a worker thread that can carry on working in the background. Another advantage of multi-threading is higher speed. The process can finish work faster by running separate threads on separate processor cores or separate processors. The disadvantage of multi-threading is That developers need to code multi-threaded programs carefully. The thread operations should be mutually exclusive or independent of each other. Otherwise problems like race conditions, or deadlocks can occur. In this process and thread for beginners video, we learned what is process, what is thread, differences in processes and threads multi threading and the benefits and drawbacks of multi-threading. That’s all in this playlist. Thank you and see you in my other video series.

4 thoughts on “Processes and Threads in operating system

Leave a Reply

Your email address will not be published. Required fields are marked *