Showing posts with label Operating System. Show all posts
Showing posts with label Operating System. Show all posts

Difference between Process and Thread. Thread vs Process.


Thread Process
An executing instance of a program is called a process. A thread is a subset of the process.
Thread shares the address space of process that they are belonging to. Processes have their own address space.
Threads have direct access to the data segment of its process. Processes have their own copy of data segment of a parent process.
Threads can directly communicate with other threads of its process. The processes must use interprocess commumnication (IPC) to communicate with other process.
Threads have less overhead with context switching. Processes have considerable overhead.
New threads can be easily created. New process requires duplications of a parent process.
Threads can exercise a considerable control over threads of a same process. Process can only exercise control over its child process.
Changes to the main thread may affect the behaviour of other threads of a process. Changes to the process does not affect the child process.
Threads (of the same process) run in a shared memory space. Processes run in separate memory spaces.
Every thread is not a process. It is a part(entity) of a process. Every process is a thread (primary thread).
Threads are light weight processes. Threads are bundled inside the process. Process is a heavy weight process.
Threads are created using clone() method. Process are created using fork() method.

What is an Operating System?

  • An operating system is a collection of programs and utilities.
  • It acts as the interface between user and computer.
  • It creates a user-friendly environment for the user.
  • The operating system acts as a resource manager.
A computer system has many resources (hardware and software) which may be required for completing a task. The computer uses resources like input/output device, memory, file, storage space, CPU time, and so on. The operating system acts as a manager of all these resources and allocates them to specific program and users as necessary for their tasks. Therefore, we can say operating system acts as a resource manager. Generally, resource sharing will be done in two ways, 'in time' and 'in space'. For example, a CPU is a time sharing resource and sharing resource and the main memory is a space sharing resource. The main difference between in time sharing and in space sharing is 'in time' resource is not divided into units, whereas in space resources is divided into units.