Networking and Operating System

Assignment Overview
This assignment is about operating systems architecture and functionality. The assignment is divided into three parts A-C. The first part is

concerned with the Windows operating system architecture, the second part is concerned with resource handling and the third part deals with

multi-threading and concurrency issues. You need to answer ALL three parts. This is an individual piece of work. Please answer questions in

full sentences. No bullet points. Put your answers into the provided answer sheet which should have your name and k-number at the top. Submit

your answer sheet as a WORD document via CANVAS. There are 50 marks in total. This assignment counts for 15% of the total mark of this module.

Question A2: Windows Event Handling – (10 marks)
The Windows Operating System and applications are event-driven. Describe how a Windows application is decoding event messages in its main

message procedure WndProc. How does the application decode a WM_COMMAND message to call the DialogBox? Refer to the source code example below.

Discuss how such an approach is beneficial for interactive applications.

Part B – Resource Management
The Operating System manages resources such as memory and CPU time which is assigned to processing entities such as processes and threads.

Multi-threading is often used to distribute heavy duty processing onto several CPU cores to speed up the processing. The O/S scheduler

distributes the threads onto different CPU cores. The Java program MultiThreading.java in the MultiThreading.zip folder in the Assignments

section on CANVAS is an application which has been prepared with multi-threading in mind.
Performance Testing
In this part you need to assess the performance of your multi-core system and how the operating system handles the distribution of the

processing. All modern PCs feature multiple processing units (multi-core and hyper-threading units). The number of processing units corresponds

to the number of graphs (logical processors) in the performance tab in the task manager. Run the MultiThreading.java application in NetBeans.

It is suggested to use NetBeans 8.01 or NetBeans 8.1. The application performs 100 million calculations and stores the result in a shared static

data array of type float. Currently the application is configured to run this processing task only once as a single thread. By changing the

values assigned to variable N you can control the number of threads which are created and each of those threads currently performs the same

number of calculations. Hence, the workload increases with N. The application will print out how long it took to complete the processing task

for each thread. Do not run any other processing tasks while assessing the performance of the system. Make sure the CPU usage is very low before

commencing the data capture.
Task B1: Data capture – (5 marks)
Take measurements on how long it takes to complete the processing for N=1 to N=8 different thread scenarios. The applications prints out the

number of seconds for each of the N threads. Create a table in Excel and insert the longest time in seconds in the table for each scenario.

Plot a line graph with N=number of threads on the x-axis and the longest time it took to complete the processing on the y-axis. Copy the

populated table and line graph into your answer sheet.
Threads 1 2 3 4 5 6 7 8
Time to complete (sec) all cores 175 seconds 176 seconds 105 seconds 154 seconds 105 seconds 104 seconds 105

seconds 104 seconds

Task B2: Analysis – (5 marks)
Describe how the OS scheduler is distributing the processing between different CPU cores. This can be observed in the performance tab of the

task manager. How many CPU cores are busy? Give an explanation of your observations. How efficient is the computer system at handling the

increasing processing demand? Substantiate your answer by referring to the graph from task B1.
Part C – Multi-threading
Currently the application is performing the same calculations for all threads. The aim of multithreading is to share and distribute the

processing over several CPU cores in order to reduce the overall processing time.
Task C1: Data capture – (10 marks)
Modify the MultiThreading.java application so that the processing of the 100 million calculations is divided up between two and then four

threads equally. Make use of the thread id member variable to distinguish between threads in the run method.
Take measurements (max time to completion for all threads) and populate the table below when the processing is divided between 1,2, and 4

threads. Take the max time to completion for each of those configurations and add them to the table below.
Proposed table layout:
Threads 1 2 4

Copy the data into an Excel spreadsheet and plot a line graph. Copy the table and the line graph into your answer sheet.
Task C2: Analysis – (10 marks)
Comment on the efficiency of the application’s ability to process the data in parallel. Substantiate your answer by referring to the graph you

plotted for task C1 and by performing some additional calculations such as for the speedup when using 2 and 4 threads. Provide an explanation

for your observations. What are the potential limitations for parallel processing? Discuss Amdahl’s Law in this context.

WE ACCEPT