Parallel Programming 1
Parallel Programming 1
CPU cores. Remember to take into account the dependencies between the
processes shown in Figure 1.
Time 10 20 30 40 50
CPU1 P1 P3 P4 P6 P7
CPU2 P2 n/a P5 n/a n/a
1b) Please complete the following table showing the most efficient scheduling for 4
CPU cores. Remember to consider the dependencies between the processes shown
in Figure 1.
Time 10 20 30 40
CPU1 P1 P3 P4 P7
CPU2 P2 n/a P5 n/a
CPU3 n/a n/a P6 n/a
CPU4 n/a n/a n/a n/a
class Program
class PrintNum
Thread.Sleep(1000);
Console.WriteLine(count);
2a)
Please show how the code in Column 1 of Figure 2 can be modified to produce the
output shown in Figure 3.
I introduced the code synchronized static void means that only one thread from the
class can enter at a time. We used static because if we didn’t then every thread
would end up seeing its own synchronization.
2b) With particular reference to the Java programming environment please
describe the difference between a Process and a Thread.
A process is the execution of a computer program however a thread is a subset of a
process, it is a single execution that is within the process. Furthermore, a process is
heavyweight whereas a thread is lightweight, the reason for this is because the
thread have their own stack and can access shared data but a process contains it’s
own address space and processes are created to perform the work in a parallel.
Another difference between the two is the process consumes more resources
compared to the thread, also the communication in a process is complex whereas in
a thread it is a lot easier and efficient. Finally, if a process crashes then it won’t affect
the other processes however if a thread crashes it will crash all the other threads.
Powered by TCPDF (www.tcpdf.org)