CS3530 Assignment 4


Kennesaw State University


Department of Computer Science
Operating Systems CS3530/01
Assignment # 4 / Synchronization




Dalibor Labudovic



06/26/12013









Initial Problem Statement:
Study the behavior of synchronization: the simulation models implemented in "consprod.cpp" and "reawriter.cpp"

  1. Run the simulation models as is, then change the delay on the critical section of the producer and consumer processes.
  2. Compare the performance of the two simulation runs.
  3. The parameters are hard-coded so you have to edit the source program and recompile.

  1. Change (decrease) the inter-arrival intervals for readers
  2. Change the delay on the critical section of the writer processes.
  3. Compare the performance of the two simulation runs.

In the last part of your report include your answers to the following questions.


1. What are the main differences between the two models and with the previous models?
2. Explain how synchronization affects the behavior of the processes in the simulation run.
3. Identify the "slower" process in the simulation runs.
4. What aspect of an operating system is the model representing?
5. What performance measures does the model compute?
6. What is noticeable in the dynamic behavior of the system?
7. What other performance measures can this model compute?
Summary and purpose of the assignment activity:
The purpose of the assignment is to compare and contract the differences between two types of synchronization. We have been give two simulation models, there are some perimeters which can be modified but they have to be hard-coded, recompiled and run again. With modification to the simulation models we are able to determine the way a synchronization type will behave.
To summarize assignment activity is to provide the results from comparison and contrast results. Please follow the section
Detail description of the solution and used in the project:
In this project we have the opportunity to change the parameters within the code and with those changes are able to compare the non modified results with modified results. With that said, I initially ran both simulation without changes, the results are posted below under Table of Results sun tabbed No changes. The next process is to change they delay for critical section. Under Table of Results, changed delay, you will find the results for delayed time for the critical section. Finally, I processed to change decreased the inter-arrival interval time for readers. Those results are under Table of Results, delayed inter-arrival interval for readers.
Table of results:
No Changes
Consprod
Psim3 project: Consumer-Producer Synchronization
Simulation date: Wed Jun 26 14:58:54 2013


-------------------------------------------------------------
Mutex Sem % usage: 0.234521 avg num items used: 1
% of time spent in res usage: 0.234521
% of time spent waiting: 0.00786966
-------------------------------------------------------------
-------------------------------------------------------------
Full Sem
Number of operations requesting items: 40
Maximum number of items: 24, avg num free items: 22.3127

--------------------------------------------------------
-------------------------------------------------------------
Empty Sem
Number of operations requesting items: 64
Maximum number of items: 23, avg num free items: 8.46992
Avg waiting time: 12.0703Avg. num waiting processes: 1
--------------------------------------------------------

Bounded- Buffer Simulation Results:
Producer total wait time: 1486.99
Consumer total wait time: 34.4692
--------------------------------------------------
End of simulation Consumer-Producer Synchronization Wed Jun 26 14:58:54 2013

Reawriter

-------------------------------------------------------------
MUTEX % usage: 0.226721 avg num items used: 1
% of time spent in res usage: 0.226721
% of time spent waiting: 0.17926
-------------------------------------------------------------
-------------------------------------------------------------
WRT
Number of operations requesting items: 125
Maximum number of items: 1, avg num free items: 0
Avg waiting time: 2.65647Avg. num waiting processes: 10.9369
--------------------------------------------------------
Total readers that arrived: 130
Total writers that arrived: 80
Total readers that completed: 130
Total writers that completed: 80
Average readers wait period: 7.51003
Average writers wait period: 5.08441
--------------------------------------------------
End of simulation Concurrent Readers/Writers Problem Wed Jun 26 14:57:09 2013

Changed Delay
Consprod

Psim3 project: Consumer-Producer Synchronization
Simulation date: Wed Jun 26 15:00:23 2013


-------------------------------------------------------------
Mutex Sem % usage: 0.274919 avg num items used: 1
% of time spent in res usage: 0.274919
% of time spent waiting: 0.0172073
-------------------------------------------------------------
-------------------------------------------------------------
Full Sem
Number of operations requesting items: 49
Maximum number of items: 24, avg num free items: 22.7588

--------------------------------------------------------
-------------------------------------------------------------
Empty Sem
Number of operations requesting items: 73
Maximum number of items: 24, avg num free items: 5.52131
Avg waiting time: 19.4052Avg. num waiting processes: 1
--------------------------------------------------------

Bounded- Buffer Simulation Results:
Producer total wait time: 1042.76
Consumer total wait time: 65.2317
--------------------------------------------------
End of simulation Consumer-Producer Synchronization Wed Jun 26 15:00:23 2013

Reawriter
------------------------------------------------------------
MUTEX % usage: 0.30621 avg num items used: 1
% of time spent in res usage: 0.30621
% of time spent waiting: 0.18977
-------------------------------------------------------------
-------------------------------------------------------------
WRT
Number of operations requesting items: 150
Maximum number of items: 1, avg num free items: 0
Avg waiting time: 2.1787Avg. num waiting processes: 28.9341
--------------------------------------------------------
Total readers that arrived: 150
Total writers that arrived: 106
Total readers that completed: 150
Total writers that completed: 106
Average readers wait period: 5.96909
Average writers wait period: 4.26097
--------------------------------------------------
End of simulation Concurrent Readers/Writers Problem Wed Jun 26 16:16:17 2013


Decreased inter-arrival interval for readers:

UTEX % usage: 0.259913 avg num items used: 1
% of time spent in res usage: 0.259913
% of time spent waiting: 0.181293
-------------------------------------------------------------
-------------------------------------------------------------
WRT
Number of operations requesting items: 127
Maximum number of items: 1, avg num free items: 0
Avg waiting time: 2.57795Avg. num waiting processes: 8.36729
--------------------------------------------------------
Total readers that arrived: 124
Total writers that arrived: 82
Total readers that completed: 124
Total writers that completed: 82
Average readers wait period: 4.95978
Average writers wait period: 2.57944
--------------------------------------------------
 End of simulation Concurrent Readers/Writers Problem Wed Jun 26 16:19:07 2013


Comments and Conclusion:
In conclusion, synchronization and semaphore policies are an important role to be taught and understood for the better organization and background information when it comes to programming and consulting possibilities and undermining within the limits of the system. From this assignment, I have better understood the fundamentals of the synchronization and roles of semaphore, and with this understanding I am able to better justify ins and outs usage of the resources within the connection of the software and hardware.


Questions and Answers:
1. What are the main differences between the two models and with the previous models?
The main difference is that the previous models and this model is how the perimeters are modified. For previous simulation models you are able to set perimeters after you have run the simulation, with this model, you can only change the perimeters in the code, also called hard-coded changes.

2. Explain how synchronization affects the behavior of the processes in the simulation run.
Synchronization can either delay or speed up the processes in the simulation. This can be performed with adjustments to the either semaphore perimeters or adjust the critical section process time. From my observation when adjusting the critical section process time with the increase time, the performance suffered. While adjusting the inter-arrival interval time for readers, this semaphore perimeters modification two results have been shown, with delayed time I observed shorter wait time but less processes completed.

3. Identify the "slower" process in the simulation runs.
The slower process in the simulation run were the original simulation models. This is that I observed while comparing modified vs non-modified simulation models.

4. What aspect of an operating system is the model representing?
This simulation models represents the synchronization aspect of the OS and the how the OS manages shared resources.

5. What performance measures does the model compute?
The simulation model computes the wait time for reader and writer. Also, the number of processes arrived, number of processes reader processed and number of processes writer processed.

6. What is noticeable in the dynamic behavior of the system?
From my results, this simulation system didn't display any dynamic behavior, the simulation model was very static because all of its parameters are hard-coded.

7. What other performance measures can this model compute?
From this assignments simulation model we can measure overall better synchronization and semaphore performance. With the combination of both of these simulation model results and compare and contrast the parameters changes, we can correlate a better overall design in the real system.

Script:
Script started on Wed 26 Jun 2013 02:56:06 PM EDT
#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ ./psim3c consprod.cpp
#[H#[2J#[H#[2J-------------------------------------------------------------------------------
------ Psim3 C++ (POSIX threads) package for object oriented simulation -------
------------------ (C) J. M. Garrido, 2004-2012 -----------
-------------------------------------------------------------------------------
a.out created.
#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ ./a.out | tee consprod.txt
Psim3 project: Consumer-Producer Synchronization
Simulation date: Wed Jun 26 14:56:36 2013
-------------------------------------------------------------
Mutex Sem % usage: 0.29219 avg num items used: 1
% of time spent in res usage: 0.29219
% of time spent waiting: 0.0175013
-------------------------------------------------------------
-------------------------------------------------------------
Full Sem
Number of operations requesting items: 54
Maximum number of items: 24, avg num free items: 20.4329
--------------------------------------------------------
-------------------------------------------------------------
Empty Sem
Number of operations requesting items: 76
Maximum number of items: 24, avg num free items: 8.43778
Avg waiting time: 0.574344Avg. num waiting processes: 1
--------------------------------------------------------

Bounded- Buffer Simulation Results:
Producer total wait time: 787.502
Consumer total wait time: 48.5586
--------------------------------------------------
End of simulation Consumer-Producer Synchronization Wed Jun 26 14:56:36 2013
#[m#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ ./psim3c reawriter.cpp
#[H#[2J#[H#[2J-------------------------------------------------------------------------------
------ Psim3 C++ (POSIX threads) package for object oriented simulation -------
------------------ (C) J. M. Garrido, 2004-2012 -----------
-------------------------------------------------------------------------------
a.out created.
#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ ./a.o0t##[K##[Kut | tee reawriter.txt
Psim3 project: Concurrent Readers/Writers Problem
Simulation date: Wed Jun 26 14:57:09 2013
-------------------------------------------------------------
MUTEX % usage: 0.226721 avg num items used: 1
% of time spent in res usage: 0.226721
% of time spent waiting: 0.17926
-------------------------------------------------------------
-------------------------------------------------------------
WRT
Number of operations requesting items: 125
Maximum number of items: 1, avg num free items: 0
Avg waiting time: 2.65647Avg. num waiting processes: 10.9369
--------------------------------------------------------
Total readers that arrived: 130
Total writers that arrived: 80
Total readers that completed: 130
Total writers that completed: 80
Average readers wait period: 7.51003
Average writers wait period: 5.08441
--------------------------------------------------
End of simulation Concurrent Readers/Writers Problem Wed Jun 26 14:57:09 2013
$ ./psim3x##[Kc n##[Kcansprod.cpp
#[H#[2J#[H#[2J-------------------------------------------------------------------------------
------ Psim3 C++ (POSIX threads) package for object oriented simulation -------
------------------ (C) J. M. Garrido, 2004-2012 -----------
-------------------------------------------------------------------------------
g++: cansprod.cpp: No such file or directory
a.out created.
#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ clear##[K##[K##[K##[K##[Ka##[K#clear
#[H#[2J#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ /.##[K##[K./psim3c consprod.cpp
#[H#[2J#[H#[2J-------------------------------------------------------------------------------
------ Psim3 C++ (POSIX threads) package for object oriented simulation -------
------------------ (C) J. M. Garrido, 2004-2012 -----------
-------------------------------------------------------------------------------
a.out created.
#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ ./a.out | tee consprod.y##[Ktxt
Psim3 project: Consumer-Producer Synchronization
Simulation date: Wed Jun 26 14:58:54 2013


-------------------------------------------------------------
Mutex Sem % usage: 0.234521 avg num items used: 1
% of time spent in res usage: 0.234521
% of time spent waiting: 0.00786966
-------------------------------------------------------------
-------------------------------------------------------------
Full Sem
Number of operations requesting items: 40
Maximum number of items: 24, avg num free items: 22.3127
--------------------------------------------------------
-------------------------------------------------------------
Empty Sem
Number of operations requesting items: 64
Maximum number of items: 23, avg num free items: 8.46992
Avg waiting time: 12.0703Avg. num waiting processes: 1
--------------------------------------------------------

Bounded- Buffer Simulation Results:
Producer total wait time: 1486.99
Consumer total wait time: 34.4692
--------------------------------------------------
End of simulation Consumer-Producer Synchronization Wed Jun 26 14:58:54 2013

./psim3c##[Kx##[Kc consprod.cpp
#[H#[2J#[H#[2J-------------------------------------------------------------------------------
------ Psim3 C++ (POSIX threads) package for object oriented simulation -------
------------------ (C) J. M. Garrido, 2004-2012 -----------
-------------------------------------------------------------------------------
a.out created.
#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ /##[K./a.out | constrpd##[K##[K##[K##[Kprod2.cpp##[K##[K##[Ktxt
bash: consprod2.txt: command not found
#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ ./a.out | tee consprod2.txt
Psim3 project: Consumer-Producer Synchronization
Simulation date: Wed Jun 26 15:00:23 2013

-------------------------------------------------------------
Mutex Sem % usage: 0.274919 avg num items used: 1
% of time spent in res usage: 0.274919
% of time spent waiting: 0.0172073
-------------------------------------------------------------
-------------------------------------------------------------
Full Sem
Number of operations requesting items: 49
Maximum number of items: 24, avg num free items: 22.7588

--------------------------------------------------------
-------------------------------------------------------------
Empty Sem
Number of operations requesting items: 73
Maximum number of items: 24, avg num free items: 5.52131
Avg waiting time: 19.4052Avg. num waiting processes: 1
--------------------------------------------------------
Bounded- Buffer Simulation Results:
Producer total wait time: 1042.76
Consumer total wait time: 65.2317
--------------------------------------------------
End of simulation Consumer-Producer Synchronization Wed Jun 26 15:00:23 2013

[ Wrote 320 lines ]#(B#[m#[K#[41;144H#[41;1H#[?1049l #[?1l#>#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ ./psim3c w##[Ke##[Kreawriter.cpp
#[H#[2J#[H#[2J-------------------------------------------------------------------------------
------ Psim3 C++ (POSIX threads) package for object oriented simulation -------
------------------ (C) J. M. Garrido, 2004-2012 -----------
-------------------------------------------------------------------------------
a.out created.
#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ ./a.out | tee reawriter2.cp##[K##[Ktxt
Psim3 project: Concurrent Readers/Writers Problem
Simulation date: Wed Jun 26 16:16:17 2013

Readers_Writers created
-------------------------------------------------------------
MUTEX % usage: 0.30621 avg num items used: 1
% of time spent in res usage: 0.30621
% of time spent waiting: 0.18977
-------------------------------------------------------------
-------------------------------------------------------------
WRT
Number of operations requesting items: 150
Maximum number of items: 1, avg num free items: 0
Avg waiting time: 2.1787Avg. num waiting processes: 28.9341
--------------------------------------------------------
Total readers that arrived: 150
Total writers that arrived: 106
Total readers that completed: 150
Total writers that completed: 106
Average readers wait period: 5.96909
Average writers wait period: 4.26097
--------------------------------------------------
End of simulation Concurrent Readers/Writers Problem Wed Jun 26 16:16:17 2013

#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ nano rew##[Kawriter.co##[Kpp
dlabudov]$ ./psim3c rew##[Kawriter.cpp
#[H#[2J#[H#[2J-------------------------------------------------------------------------------
------ Psim3 C++ (POSIX threads) package for object oriented simulation -------
------------------ (C) J. M. Garrido, 2004-2012 -----------
-------------------------------------------------------------------------------
a.out created.
#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ ./a.out.##[K reawriter.cpp ##[K##[K##[K##[K##[K##[K##[K##[K##[K##[K##[K##[K##[K##[K| tee reawriter4.cpp
Psim3 project: Concurrent Readers/Writers Problem
Simulation date: Wed Jun 26 16:19:07 2013
-------------------------------------------------------------
MUTEX % usage: 0.259913 avg num items used: 1
% of time spent in res usage: 0.259913
% of time spent waiting: 0.181293
-------------------------------------------------------------
-------------------------------------------------------------
WRT
Number of operations requesting items: 127
Maximum number of items: 1, avg num free items: 0
Avg waiting time: 2.57795Avg. num waiting processes: 8.36729
--------------------------------------------------------
Total readers that arrived: 124
Total writers that arrived: 82
Total readers that completed: 124
Total writers that completed: 82
Average readers wait period: 4.95978
Average writers wait period: 2.57944
--------------------------------------------------
End of simulation Concurrent Readers/Writers Problem Wed Jun 26 16:19:07 2013


#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ exit
exit

Script done on Wed 26 Jun 2013 04:19:17 PM EDT

Comments

Popular posts from this blog

How to clear & format SD card

Sharepoint List: Days Elapsed or Countdown

CS4500 Test 4 Study Guide