Interview Questions and Answers :: Ciena
Home > Experience Archives > Ciena > Interview Question Set 1 > Discussion
15. What is difference between process and thread, how communication happen between them. what is shared between them.
Answer:
- Threads can directly communicate with other threads of its process; processes must use inter process communication to communicate with sibling processes.
- Both process and threads are independent path of execution but one process can have multiple Threads.
- Each process has its own code, data and kernel context (VM structures, descriptor table, etc). While the threads of a process, they share the same code, data and kernel context.
- New threads are easily created. However the creation of new processes require duplication of the parent process.
- Threads are created using clone() method. Process are created using fork() method.
- Processes are heavily dependent on system resources available while threads require minimal amounts of resource, so a process is considered as heavyweight while a thread is termed as a lightweight process.
- Context switch between the threads are not much time consuming. Context switch between the process is time consuming.
- Processes never share the same memory. When a child process creates it duplicates the memory location of the parent process. Process communication is done by using pipe, shared memory, and message parsing.
- Threads within the same process share the Memory(heap/global), but each thread has its own stack and registers, and threads store thread-specific data in the heap. Threads never execute independently, so the inter-thread communication is much faster when compared to inter-process communication.
- each thread has its own stack, having its own stack allow to have its own execuation context.
Shubham
2 Apr, 2018 11:11 PM
- Threads can directly communicate with other threads of its process; processes must use inter process communication to communicate with sibling processes.
- Both process and threads are independent path of execution but one process can have multiple Threads.
- Each process has its own code, data and kernel context (VM structures, descriptor table, etc). While the threads of a process, they share the same code, data and kernel context.
- New threads are easily created. However the creation of new processes require duplication of the parent process.
- Threads are created using clone() method. Process are created using fork() method.
- Processes are heavily dependent on system resources available while threads require minimal amounts of resource, so a process is considered as heavyweight while a thread is termed as a lightweight process.
- Context switch between the threads are not much time consuming. Context switch between the process is time consuming.
- Processes never share the same memory. When a child process creates it duplicates the memory location of the parent process. Process communication is done by using pipe, shared memory, and message parsing.
- Threads within the same process share the Memory(heap/global), but each thread has its own stack and registers, and threads store thread-specific data in the heap. Threads never execute independently, so the inter-thread communication is much faster when compared to inter-process communication.
- each thread has its own stack, having its own stack allow to have its own execuation context.
Report Error
Report Error
Please Login First Click Here