Part B: Here is a redesign of the web server using appropriate thread primitives.
repeat await request from client c for file f create a new thread to do the following establish connection to c open f repeat for each sector of f send the sector over the connection to c until all sectors sent terminate connection to c end of new thread forever
Part C: If the above design is deluged with thousands of requests from far away users, the time it takes to begin service of one user request may be reasonably fast, but there will be many threads competing to do read operations, so the time to read and transmit the file entire file may be unreasonably slow.
There is probably an optimal number of threads that will lead to the best service, probably a number of threads that is a small integer multiple of the number of disk drives. If we limit the number of threads to this number, a high traffic server would delay its reply with the first requested sector, but it would deliver the successive sectors of each file quite quickly.
Second, in multithreaded systems where there are multiple processes acting as virtual CPUs to run threads from one shared application, the only shared variables are typically in a shared heap. The static variables of the code are typically on the base of the stack, in private variables of each process. In this context, each thread runs on a stack in the shared heap, so the local variables of a thread are properly shared, but the global variables are not shared! So, to share variables that are logically global, they must be allocated from the shared heap and accessed by pointer.
The size of the process representation that must be moved
The size of the file itself
The size of the part of the file that is to be accessed
Part B: A small process that acceses an entire large file should be moved to the machine that has that file. A small file that is accessed by a large application should be moved to the machine holding that application. If the part of the file that is to be accessed is smaller than both the file and the process that accesses the file, only that part should be moved, and neither the file nor the process should migrate.