Team-FLY |
17.7 Concurrent TasksModify the program to allow multiple computations and tasks. Use a MAX_TASKS value of 10 for this part. A new NEWTASK packet may come in before the data from previous tasks has been completely transmitted. When a new NEWTASK packet comes in, find an available slot in the tasks object, create a new set of pipes, and fork a new child to execute the command. Don't enter any duplicates in the tasks array. Figure 17.9 shows a schematic of a threaded NTPVM dispatcher that supports multiple simultaneous tasks. When another request comes in, the input thread creates a new output thread. Since multiple output threads write to standard output, define an additional mutex lock to synchronize output on the dispatcher's standard output. Figure 17.9. Schematic of a threaded NTPVM dispatcher.
|
Team-FLY |