Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1.When a multi-threaded process forks, there\'s a chance that a problem could oc

ID: 3665154 • Letter: 1

Question

1.When a multi-threaded process forks, there's a chance that a problem could occur if the child gets copies of all the parent's threads. Consider what would happen if one of the original threads were waiting for some input from the keyboard. That would mean that there are now two threads waiting for input from the keyboard, one in each process. Would this problem ever occur in a single-threaded process Explain your answer.

2. The book described a multi-threaded Web server, and explains why it is better than a single-threaded server. Can you think of any circumstances where a single-threaded server might actually be better than a multi-threaded one? Give an example

3.In class we talked about a number of advantages and some of the disadvantages of implementing threads in user space. What would you consider to be one of the biggest advantages? What would you consider to be the biggest disadvantage?

Explanation / Answer

3)The biggest advantage is that context switching between threads is faster because it does not require a trap into the kernel.
The biggest disadvantage is that, if a user thread blocks in the kernel (e.g., waiting for I/O), no other threads in the process can run.
2) So when processing a task in a thread is trivial, the cost of creating a thread will create more overhead than distributing the task. This is one case where a single thread will be faster than multithreading.
   If you start more threads as cores are available, the thread management of your OS will spend more and more time in Thread-Switches and in such your efficiency using your CPU(s) becomes worse.
   Single-threaded servers are the way to go because it makes it easier to implement a good cycle-based design into the server (and cycle based designs are the way RuneScape should be!). If you tried making a cycle-based design in a multi-threaded server you'd have to be careful with your synchronization, which could be a hassle.
Advantages of a single-threaded server:

•   No threading issues
•   No synchronization issues
•   Simple and efficient
1)   NO, this problem would never occur in Single threaded process.
Because in single threaded process at a time only one process will be executed. That means execution of process can be done one by one (linearly)