Join Onbux For Free and Earn Money

Showing posts with label OS. Show all posts
Showing posts with label OS. Show all posts

Multitasking



Multitasking is a method with multiple processes share common resources like CPU. Multiprocessing is similar to multitasking, but in multiprocessing more than one CPU is involved. In multitasking only one CPU is involved, the CPU is switched from one task to another so quickly, so that each user gets the impression that CPU is used by him only.


There are two types of multitasking: Preemtive and Cooperative multitasking. In preemptive multitasking, operating systems assigns time slice to each processes that are waiting for the execution. When the time slice of an executing program has expired, that process is taken from the CPU and the waiting process gets a chance to use CPU. In cooperative multitasking, each program can control the CPU as long as it needs it. Unlike in preemptive multitasking, here program itself owns the control of CPU.

Process vs Threads


A process is an executing instance of an application. For example when you double click on a word program, a new process starts. When a process starts, a separate memory area is created for that process.

A process consists of several executable programs called threads, that works together as a whole. Process are heavyweight tasks and threads are light weight tasks. For example, when you start the word program, the autosave and spell check features are running in the background and these are called threads which operate on the same data set.

Threads with in the same process share the same address space. Therefore, this allows communication between threads and also allows thread to read and write to the same data structures.