Explain the difference between a process and a thread with some examples.

 Explain the difference between a process and a thread with some examples. …………………………………………………………………………….. …………..…………………………………………………………………

1) A process is an instance of an executing program and its data. For example, if you were editing 3 files simultaneously, you would have 3 processes, even though they might be sharing the same code. 

 A thread is often called a lightweight process. It is a “child” and has all the state information associated with a child process but does not run in a separate address space i.e., doesn’t have its own memory. Since they share memory, each thread has access to all variables and any change made by one thread impacts all the others. Threads are useful in multi-client servers where each thread can service a separate client connection. In some stand-alone processes where you can split the processing such that one thread can continue processing while another is blocked e.g., waiting for an I/O request or a timer thread can implement a regular repaint of a graphics canvas.

This is how simple animations are accomplished in systems like NT and Windows95. Unix is a single-threaded operating system and can’t do this at the operating system level although some applications e.g., Java can support it via software.


No comments:

Post a Comment