Question-1 Write the short note on Multithreading and Multitasking.
- The ability of an operating system to execute different parts of a program, called threads simultaneously, is called multithreading.
- The programmer must carefully design the program in such a way that all the threads can run at the same time without interfering with each other.
- On a single processor, multithreading generally occurs by time division multiplexing (as in multitasking) the processor switches between different threads.
- This context switching generally happens so speedy that the user perceives the threads or tasks as running at the same time.
- The ability to execute more than one task at the same time is called multitasking.
- In multitasking, only one CPU is involved, but it switches from one program to another so quickly that it gives the appearance of executing all of the programs at the same time.
There are two basic types of multitasking.
1) Preemptive: In preemptive multitasking, the operating system assign CPU time slices to each program.
2) Cooperative: In cooperative multitasking, each program can control the CPU for as long as it needs CPU. If a program is not using the CPU, however, it can allow another program to use it.
Question-2 Write the similarities and dissimilarities (difference) between process and thread.
- Like processes threads share CPU and only one thread is active (running) at a time.
- Like processes threads within a process execute sequentially.
- Like processes thread can create children.
- Like a traditional process, a thread can be in any one of several states: running, blocked, ready, or terminated.
- Like process threads have Program Counter, stack, Registers and state.
- Unlike processes threads are not independent of one another, threads within the same process share an address space.
- Unlike processes all threads can access every address in the task.
- Unlike processes threads are design to assist one other. Note that processes might or might not assist one another because processes may be originated from different users.
You may be interested in:
Operating System Short Descriptive Questions and Answers