0% found this document useful (0 votes)
9 views

Parallel Programming 1

Uploaded by

Denis Mcdenoh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Parallel Programming 1

Uploaded by

Denis Mcdenoh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

1a) Please complete the following table showing the most efficient scheduling for 2

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

1c) Please describe the importance of dependencies in the scheduling of parallel


processes

Dependencies are important in the scheduling of parallel processing as a process


cannot start without the dependant process finishing unless it has no dependencies.
If there are a lot of dependencies then it will take longer so the scheduling will need
to be longer, however the less dependencies means that more processes can start at
the same time, however it also depends on the amount of processors as if there is
only one processor then it can handle one process at a time. so, the overall
scheduling of parallel process is determined by the dependencies.
Column 1 Code Column2: Output

class Program

public static void Main(string[] args)


counter = 30036
{
counter = 45656
PrintNum p = new PrintNum();
counter = 14571
Thread t1 = new Thread(new
ThreadStart(p.DisplayN)); counter = 43555

Thread t2 = new Thread(new counter = 13751


ThreadStart(p.DisplayN));
counter = 27062
t1.Start();
counter = 28119
t2.Start();
counter = 47566
}

class PrintNum

public void DisplayN ()


{

for (int count = 1; count <= 100; count++)

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)

You might also like