CS3530 Assignment 5
Kennesaw State University
Department of Computer Science
Operating Systems CS3530/01
Assignment # 5 / Deadlock
Dalibor Labudovic
07/09/12013
Initial Problem Statement:
Study of Deadlocks with the Five Philosophers Problem.
This assignment involves observation of general behavior of a system with deadlock situations and solutions. Computation of some relevant performance metrics.
There are three models implemented in C++ using Psim3 package:
"philos.cpp", "philoshw.cpp", and "philoscw.cpp".
The first model always deadlocks.
The second model applies the dis-allowance of the hold and wait condition as a solution to deadlock.
The third model applies dis-allowance of the circular wait condition as a solution to deadlock.
Copy the model source C++ files from the system directory on the CS3 server, then compile, and link to create the executable program.
Run the program at least three times. Change the average parameter for the eating and thinking periods, and compare results.
Write a report describing the characteristics of the operating system modeled. Use the usual guidelines for structuring the report.
At the end of your report, include at the end of the report your answers to the following questions:
* What aspect of an operating system is the model representing?
* What performance measures does the model compute?
* What is noticeable in the dynamic behavior of the system?
* After changing some of the parameters in the model (the workload) and recompiling. What changes in the results do you notice?
* What other performance measures can this model compute?
As usual, use the guidelines on the course web page for structuring your report.
Summary and purpose of the assignment activity:
The purpose of this assignment activity is to experience the results of a dead lock and also run two simulation to solve the deadlock occurrence. With these simulation run, we are able to better understand the deadlock occurrence and we will have a deeper meaning of how to go about solving the issue.
To summarize the assignment activity, deadlock occurrence is worse then starvation because it ties up resources . There are two ways to solve deadlock occurrence and they are to dis-allow hold and wait conditions and to dis-allow circular wait conditions.
Detail description of the solution and used in the project:
In this report the assignment had three simulation models. One is the deadlock occurrence, where there is a deadlock and none of the philosophers are able to think nor eat because of their required resources are not available. For this first deadlock occurrence, we are to run the simulation three times, then modified a parameter within the simulation program to compare the differences.
The second simulation model is the dis-allowance of the hold and wait condition to solve the deadlock, again we are to run this simulation program three times and the fourth time we are to modify a parameter within the program, then compare and contrast the results.
Third simulation model is the dis-allowance of the circular wait condition to solve deadlock, again we are run this simulation program three times and the fourth time, we are to modify a parameter within the program, then compare and contrast the results.
Table of results:
Philos run 1:
fork4 % usage: 0
fork3 % usage: 0
fork2 % usage: 0
fork1 % usage: 0
fork0 % usage: 0
Philos run 2:
fork4 % usage: 0
fork3 % usage: 0
fork2 % usage: 0
fork1 % usage: 0
fork0 % usage: 0
Philos run 3:
fork4 % usage: 0
fork3 % usage: 0
fork2 % usage: 0
fork1 % usage: 0
fork0 % usage: 0
Philos modified run:
fork4 % usage: 0
fork3 % usage: 0
fork2 % usage: 0
fork1 % usage: 0
fork0 % usage: 0
Phioscw run 1:
fork4 % usage: 0.632073 avg num items used: 1
% of time spent in res usage: 0.632073
% of time spent waiting: 0.234163
fork3 % usage: 0.580245 avg num items used: 1
% of time spent in res usage: 0.580245
% of time spent waiting: 0.170316
fork2 % usage: 0.513805 avg num items used: 1
% of time spent in res usage: 0.513805
% of time spent waiting: 0.28587
fork1 % usage: 0.64489 avg num items used: 1
% of time spent in res usage: 0.64489
% of time spent waiting: 0.214496
fork0 % usage: 0.811469 avg num items used: 1
% of time spent in res usage: 0.811469
% of time spent waiting: 0.420307
-------------------------------------------------------------
Number of eating cycles phil 0 = 8
Total waiting interval to eat phil 0 = 101.17
Number of eating cycles phil 1 = 5
Total waiting interval to eat phil 1 = 79.3788
Number of eating cycles phil 2 = 6
Total waiting interval to eat phil 2 = 51.1304
Number of eating cycles phil 3 = 7
Total waiting interval to eat phil 3 = 13.298
Number of eating cycles phil 4 = 9
Total waiting interval to eat phil 4 = 103.811
Average interval waiting to eat: 69.7577
Philoscw run 2:
fork4 % usage: 0.593486 avg num items used: 1
% of time spent in res usage: 0.593486
% of time spent waiting: 0.270576
fork3 % usage: 0.784031 avg num items used: 1
% of time spent in res usage: 0.784031
% of time spent waiting: 0.287356
fork2 % usage: 0.744413 avg num items used: 1
% of time spent in res usage: 0.744413
% of time spent waiting: 0.305216
fork1 % usage: 0.790898 avg num items used: 1
% of time spent in res usage: 0.790898
% of time spent waiting: 0.298654
fork0 % usage: 0.879005 avg num items used: 1
% of time spent in res usage: 0.879005
% of time spent waiting: 0.50522
-------------------------------------------------------------
Number of eating cycles phil 0 = 4
Total waiting interval to eat phil 0 = 72.0529
Number of eating cycles phil 1 = 8
Total waiting interval to eat phil 1 = 86.3792
Number of eating cycles phil 2 = 5
Total waiting interval to eat phil 2 = 63.3861
Number of eating cycles phil 3 = 7
Total waiting interval to eat phil 3 = 80.5026
Number of eating cycles phil 4 = 9
Total waiting interval to eat phil 4 = 130.935
Average interval waiting to eat: 86.6511
Philoscw run 3:
fork4 % usage: 0.536131 avg num items used: 1
% of time spent in res usage: 0.536131
% of time spent waiting: 0.0511825
fork3 % usage: 0.574367 avg num items used: 1
% of time spent in res usage: 0.574367
% of time spent waiting: 0.0837188
fork2 % usage: 0.524719 avg num items used: 1
% of time spent in res usage: 0.524719
% of time spent waiting: 0.111445
fork1 % usage: 0.786227 avg num items used: 1
% of time spent in res usage: 0.786227
% of time spent waiting: 0.327559
fork0 % usage: 0.767227 avg num items used: 1
% of time spent in res usage: 0.767227
% of time spent waiting: 0.268049
-------------------------------------------------------------
Number of eating cycles phil 0 = 6
Total waiting interval to eat phil 0 = 90.1819
Number of eating cycles phil 1 = 8
Total waiting interval to eat phil 1 = 51.076
Number of eating cycles phil 2 = 4
Total waiting interval to eat phil 2 = 2
Number of eating cycles phil 3 = 9
Total waiting interval to eat phil 3 = 26.7711
Number of eating cycles phil 4 = 6
Total waiting interval to eat phil 4 = 56.9594
Average interval waiting to eat: 45.3977
Philoscw modified run:
fork4 % usage: 0.801396 avg num items used: 1
% of time spent in res usage: 0.801396
% of time spent waiting: 0.371017
fork3 % usage: 0.923135 avg num items used: 1
% of time spent in res usage: 0.923135
% of time spent waiting: 0.534555
fork2 % usage: 0.870512 avg num items used: 1
% of time spent in res usage: 0.870512
% of time spent waiting: 0.469977
fork1 % usage: 0.644891 avg num items used: 1
% of time spent in res usage: 0.644891
% of time spent waiting: 0.139954
fork0 % usage: 0.909789 avg num items used: 1
% of time spent in res usage: 0.909789
% of time spent waiting: 0.752047
-------------------------------------------------------------
Number of eating cycles phil 0 = 3
Total waiting interval to eat phil 0 = 84.2897
Number of eating cycles phil 1 = 5
Total waiting interval to eat phil 1 = 138.958
Number of eating cycles phil 2 = 6
Total waiting interval to eat phil 2 = 93.8562
Number of eating cycles phil 3 = 4
Total waiting interval to eat phil 3 = 149.836
Number of eating cycles phil 4 = 3
Total waiting interval to eat phil 4 = 42.4751
Average interval waiting to eat: 101.883
Philoshw run 1:
Mutex % usage: 0
fork4 % usage: 0.672824 avg num items used: 1
% of time spent in res usage: 0.672824
fork3 % usage: 0.431571 avg num items used: 1
% of time spent in res usage: 0.431571
fork2 % usage: 0.581972 avg num items used: 1
% of time spent in res usage: 0.581972
fork1 % usage: 0.613724 avg num items used: 1
% of time spent in res usage: 0.613724
fork0 % usage: 0.815491 avg num items used: 1
% of time spent in res usage: 0.815491
-------------------------------------------------------------
Number of eat cycles Philosopher00 = 8
Total waiting time to eat Philosopher00 = 50.804
Number of eat cycles Philosopher11 = 4
Total waiting time to eat Philosopher11 = 33.7411
Number of eat cycles Philosopher22 = 3
Total waiting time to eat Philosopher22 = 19.6415
Number of eat cycles Philosopher33 = 7
Total waiting time to eat Philosopher33 = 43.234
Number of eat cycles Philosopher44 = 11
Total waiting time to eat Philosopher44 = 36.6998
Average time waiting to eat: 36.8241
Philoshw run 2:
Mutex % usage: 0
fork4 % usage: 0.567401 avg num items used: 1
% of time spent in res usage: 0.567401
fork3 % usage: 0.545788 avg num items used: 1
% of time spent in res usage: 0.545788
fork2 % usage: 0.672567 avg num items used: 1
% of time spent in res usage: 0.672567
fork1 % usage: 0.548489 avg num items used: 1
% of time spent in res usage: 0.548489
fork0 % usage: 0.745428 avg num items used: 1
% of time spent in res usage: 0.745428
Number of eat cycles Philosopher00 = 9
Total waiting time to eat Philosopher00 = 23.5328
Number of eat cycles Philosopher11 = 3
Total waiting time to eat Philosopher11 = 48.4071
Number of eat cycles Philosopher22 = 3
Total waiting time to eat Philosopher22 = 0.553999
Number of eat cycles Philosopher33 = 7
Total waiting time to eat Philosopher33 = 90.8342
Number of eat cycles Philosopher44 = 9
Total waiting time to eat Philosopher44 = 55.8926
Average time waiting to eat: 43.8442
Philoshw run 3:
Mutex % usage: 0
fork4 % usage: 0.625626 avg num items used: 1
% of time spent in res usage: 0.625626
fork3 % usage: 0.444857 avg num items used: 1
% of time spent in res usage: 0.444857
fork2 % usage: 0.647479 avg num items used: 1
% of time spent in res usage: 0.647479
fork1 % usage: 0.555536 avg num items used: 1
% of time spent in res usage: 0.555536
fork0 % usage: 0.77772 avg num items used: 1
% of time spent in res usage: 0.77772
-------------------------------------------------------------
Number of eat cycles Philosopher00 = 7
Total waiting time to eat Philosopher00 = 44.4612
Number of eat cycles Philosopher11 = 5
Total waiting time to eat Philosopher11 = 38.8937
Number of eat cycles Philosopher22 = 2
Total waiting time to eat Philosopher22 = 12.2789
Number of eat cycles Philosopher33 = 6
Total waiting time to eat Philosopher33 = 86.2948
Number of eat cycles Philosopher44 = 11
Total waiting time to eat Philosopher44 = 26.7041
Average time waiting to eat: 41.7265
Philoshw modified run:
Mutex % usage: 0
fork4 % usage: 0.651499 avg num items used: 1
% of time spent in res usage: 0.651499
fork3 % usage: 0.462515 avg num items used: 1
% of time spent in res usage: 0.462515
fork2 % usage: 0.610154 avg num items used: 1
% of time spent in res usage: 0.610154
fork1 % usage: 0.620995 avg num items used: 1
% of time spent in res usage: 0.620995
fork0 % usage: 0.826116 avg num items used: 1
% of time spent in res usage: 0.826116
-------------------------------------------------------------
Number of eat cycles Philosopher00 = 8
Total waiting time to eat Philosopher00 = 45.2336
Number of eat cycles Philosopher11 = 4
Total waiting time to eat Philosopher11 = 62.1303
Number of eat cycles Philosopher22 = 2
Total waiting time to eat Philosopher22 = 9.45542
Number of eat cycles Philosopher33 = 7
Total waiting time to eat Philosopher33 = 76.105
Number of eat cycles Philosopher44 = 11
Total waiting time to eat Philosopher44 = 37.5629
Average time waiting to eat: 46.0974
Comments and Conclusion:
Conclusion thoughts on this assignment is the bitterness of not having a graphical visualization to compare the differences between the dis-allowance hold and wait and circular wait conditions. I am glad we were able to run these simulation model to better understand the occurrence of deadlock and the solutions to solve the deadlock occurrence.
Questions and Answers:
1. What aspect of an operating system is the model representing?
This model represents the resources management of the OS, the processes require certain resources and they compete or collaborate for those resources. A deadlock simulation model is an overview of what is possible when more than one process requires access to a single resource.
2. What performance measures does the model compute?
This simulation model compute the average time waiting to eat for each philosopher.
3. What is noticeable in the dynamic behavior of the system?
The noticeable behavior of the system in a dynamic way was when the parameter was changed in the philoshw modified simulation run, with the time mean think time for philosopher 2 from 45 to 65, the change on the average time waiting to eat increased but only slightly. My expectations were to have a increased average wait time to eat by dramatically.
4. After changing some of the parameters in the model (the workload) and recompiling. What changes in the results do you notice?
Surprisingly, the changes were saddle and not at all dramatic, the changed parameters where usually increased thinking time and the average waiting time to each mostly stayed close to the average time from the three previous runs or increased only slightly. In the future my experiments and simulation runs would be better analyzed when done with some graphical structure to better understand the comparison between the two model runs.
5. What other performance measures can this model compute?
Other performance measures this model can compute are the total waiting time for each philosopher, fork usage and mutex usage.
Script:
Script started on Tue 09 Jul 2013 08:14:43 PM EDT
#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ /##[K/##[K./psim3c philos.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 philos.txt
Psim3 project: Concurrent philosophers problem
Simulation date: Tue Jul 9 20:15:49 2013
-------------------------------------------------------------
fork4 % usage: 0
-------------------------------------------------------------
-------------------------------------------------------------
fork3 % usage: 0
-------------------------------------------------------------
-------------------------------------------------------------
fork2 % usage: 0
-------------------------------------------------------------
-------------------------------------------------------------
fork1 % usage: 0
-------------------------------------------------------------
-------------------------------------------------------------
fork0 % usage: 0
-------------------------------------------------------------
--------------------------------------------------
End of simulation Concurrent philosophers problem Tue Jul 9 20:15:49 2013
#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ clear
#[H#[2J#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ ./psim3c philos.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 philos2.txt
Psim3 project: Concurrent philosophers problem
Simulation date: Tue Jul 9 20:16:57 2013
-------------------------------------------------------------
fork4 % usage: 0
fork3 % usage: 0
fork2 % usage: 0
fork1 % usage: 0
fork0 % usage: 0
End of simulation Concurrent philosophers problem Tue Jul 9 20:16:57 2013
#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ clear
#[H#[2J#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ ./psim3c philos.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 philos3.txt
Psim3 project: Concurrent philosophers problem
Simulation date: Tue Jul 9 20:17:35 2013
-------------------------------------------------------------
fork4 % usage: 0
-------------------------------------------------------------
-------------------------------------------------------------
fork3 % usage: 0
-------------------------------------------------------------
-------------------------------------------------------------
fork2 % usage: 0
-------------------------------------------------------------
-------------------------------------------------------------
fork1 % usage: 0
-------------------------------------------------------------
-------------------------------------------------------------
fork0 % usage: 0
-------------------------------------------------------------
--------------------------------------------------
End of simulation Concurrent philosophers problem Tue Jul 9 20:17:35 2013
#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ cler##[Kar
#[H#[2J#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ ./psim3c philoshw.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 |te##[K##[K tee philoshw.c##[Ktxt
Psim3 project: Concurrent Philosophers - Hold & Wait
Simulation date: Tue Jul 9 20:18:09 2013
creating fork0
creating fork1
creating fork2
creating fork3
creating fork4
Concurrent Philosophers Hold & Wait created
Philosopher0 created with 15.45 9.5
Philosopher1 created with 25.45 19.5
Philosopher2 created with 45.45 35.5
Philosopher3 created with 20.45 5.5
Philosopher4 created with 7.45 12.5
Philosopher0 think interval = 17.1968
Philosopher1 think interval = 32.4803
Philosopher2 think interval = 50.5885
Philosopher3 think interval = 26.0991
Philosopher4 think interval = 8.29229
-------------------------------------------------------------
Mutex % usage: 0
-------------------------------------------------------------
-------------------------------------------------------------
fork4 % usage: 0.672824 avg num items used: 1
% of time spent in res usage: 0.672824
-------------------------------------------------------------
-------------------------------------------------------------
fork3 % usage: 0.431571 avg num items used: 1
% of time spent in res usage: 0.431571
-------------------------------------------------------------
-------------------------------------------------------------
fork2 % usage: 0.581972 avg num items used: 1
% of time spent in res usage: 0.581972
-------------------------------------------------------------
-------------------------------------------------------------
fork1 % usage: 0.613724 avg num items used: 1
% of time spent in res usage: 0.613724
-------------------------------------------------------------
-------------------------------------------------------------
fork0 % usage: 0.815491 avg num items used: 1
% of time spent in res usage: 0.815491
-------------------------------------------------------------
Number of eat cycles Philosopher00 = 8
Total waiting time to eat Philosopher00 = 50.804
Number of eat cycles Philosopher11 = 4
Total waiting time to eat Philosopher11 = 33.7411
Number of eat cycles Philosopher22 = 3
Total waiting time to eat Philosopher22 = 19.6415
Number of eat cycles Philosopher33 = 7
Total waiting time to eat Philosopher33 = 43.234
Number of eat cycles Philosopher44 = 11
Total waiting time to eat Philosopher44 = 36.6998
Average time waiting to eat: 36.8241
--------------------------------------------------
End of simulation Concurrent Philosophers - Hold & Wait Tue Jul 9 20:18:09 2013
#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ clear
#[H#[2J#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ ./psim3c philoshw.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##[K./a.out | tee ohi##[K##[K##[Kphiloshw.##[K3##[K2.txt
Psim3 project: Concurrent Philosophers - Hold & Wait
Simulation date: Tue Jul 9 20:18:40 2013
creating fork0
creating fork1
creating fork2
creating fork3
creating fork4
Concurrent Philosophers Hold & Wait created
Philosopher0 created with 15.45 9.5
Philosopher1 created with 25.45 19.5
Philosopher2 created with 45.45 35.5
Philosopher3 created with 20.45 5.5
Philosopher4 created with 7.45 12.5
Philosopher0 think interval = 15.2106
Philosopher1 think interval = 22.0463
Philosopher2 think interval = 44.7459
Philosopher3 think interval = 17.715
Philosopher4 think interval = 7.33458
-------------------------------------------------------------
Mutex % usage: 0
-------------------------------------------------------------
-------------------------------------------------------------
fork4 % usage: 0.567401 avg num items used: 1
% of time spent in res usage: 0.567401
-------------------------------------------------------------
-------------------------------------------------------------
fork3 % usage: 0.545788 avg num items used: 1
% of time spent in res usage: 0.545788
-------------------------------------------------------------
-------------------------------------------------------------
fork2 % usage: 0.672567 avg num items used: 1
% of time spent in res usage: 0.672567
-------------------------------------------------------------
-------------------------------------------------------------
fork1 % usage: 0.548489 avg num items used: 1
% of time spent in res usage: 0.548489
-------------------------------------------------------------
-------------------------------------------------------------
fork0 % usage: 0.745428 avg num items used: 1
% of time spent in res usage: 0.745428
-------------------------------------------------------------
Number of eat cycles Philosopher00 = 9
Total waiting time to eat Philosopher00 = 23.5328
Number of eat cycles Philosopher11 = 3
Total waiting time to eat Philosopher11 = 48.4071
Number of eat cycles Philosopher22 = 3
Total waiting time to eat Philosopher22 = 0.553999
Number of eat cycles Philosopher33 = 7
Total waiting time to eat Philosopher33 = 90.8342
Number of eat cycles Philosopher44 = 9
Total waiting time to eat Philosopher44 = 55.8926
Average time waiting to eat: 43.8442
--------------------------------------------------
End of simulation Concurrent Philosophers - Hold & Wait Tue Jul 9 20:18:40 2013
#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ clear
#[H#[2J#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ ./psim3c philoshw.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 o##[Kphiloshw.##[K3.txt
Psim3 project: Concurrent Philosophers - Hold & Wait
Simulation date: Tue Jul 9 20:19:22 2013
creating fork0
creating fork1
creating fork2
creating fork3
creating fork4
Concurrent Philosophers Hold & Wait created
Philosopher0 created with 15.45 9.5
Philosopher1 created with 25.45 19.5
Philosopher2 created with 45.45 35.5
Philosopher3 created with 20.45 5.5
Philosopher4 created with 7.45 12.5
Philosopher0 think interval = 14.8496
Philosopher4 think interval = 5.94668
Philosopher3 think interval = 19.6552
Philosopher2 think interval = 36.2787
Philosopher1 think interval = 24.4609
-------------------------------------------------------------
Mutex % usage: 0
-------------------------------------------------------------
-------------------------------------------------------------
fork4 % usage: 0.625626 avg num items used: 1
% of time spent in res usage: 0.625626
-------------------------------------------------------------
-------------------------------------------------------------
fork3 % usage: 0.444857 avg num items used: 1
% of time spent in res usage: 0.444857
-------------------------------------------------------------
-------------------------------------------------------------
fork2 % usage: 0.647479 avg num items used: 1
% of time spent in res usage: 0.647479
-------------------------------------------------------------
-------------------------------------------------------------
fork1 % usage: 0.555536 avg num items used: 1
% of time spent in res usage: 0.555536
-------------------------------------------------------------
-------------------------------------------------------------
fork0 % usage: 0.77772 avg num items used: 1
% of time spent in res usage: 0.77772
-------------------------------------------------------------
Number of eat cycles Philosopher00 = 7
Total waiting time to eat Philosopher00 = 44.4612
Number of eat cycles Philosopher11 = 5
Total waiting time to eat Philosopher11 = 38.8937
Number of eat cycles Philosopher22 = 2
Total waiting time to eat Philosopher22 = 12.2789
Number of eat cycles Philosopher33 = 6
Total waiting time to eat Philosopher33 = 86.2948
Number of eat cycles Philosopher44 = 11
Total waiting time to eat Philosopher44 = 26.7041
Average time waiting to eat: 41.7265
--------------------------------------------------
End of simulation Concurrent Philosophers - Hold & Wait Tue Jul 9 20:19:22 2013
#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ clear
#[H#[2J#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ ls
#[00m#[00;32ma.out#[00m #[00mComplexNum.c#[00m #[00mphiloscw.cpp#[00m #[00mreawriter.txt#[00m
#[00mbacmfcfs.txt#[00m #[00;34mcomp_mod#[00m #[00mphilos.dat#[00m #[00mresources1.dat#[00m
#[00mbasic_lib.c#[00m #[00mconsprod2.txt#[00m #[00mphiloshw2.txt#[00m #[00mresources2.dat#[00m
#[00mbasic_lib.h#[00m #[00mconsprod.cpp#[00m #[00mphiloshw3.txt#[00m #[00mresources.dat#[00m
#[00mbatchmio1.dat#[00m #[00mconsprod.dat#[00m #[00mphiloshw.cpp#[00m #[00mscriptassignment2.txt#[00m
#[00mbatchmio2.dat#[00m #[00mconsprod.txt#[00m #[00mphiloshw.dat#[00m #[00mscriptassignment4.txt#[00m
#[00mbatchmio.cpp#[00m #[00mdistance.c#[00m #[00mphiloshw.txt#[00m #[00mscriptassignment5.txt#[00m
#[00mbatchmio.dat#[00m #[00mfreefall.c#[00m #[00mphilos.txt#[00m #[00mstrddev.c#[00m
#[00mbatmfcfs.cpp#[00m #[00mheight.c#[00m #[00;32mpsim3c#[00m #[00mtsmult.cpp#[00m
#[00mbatmfcfs.dat#[00m #[00;34mmyos#[00m #[00mrainfall.c#[00m #[00mtsmult.dat#[00m
#[00mbatmfcfs.txt#[00m #[00;32mmysession1.txt#[00m #[00mreawriter2.txt#[00m #[00mtsmult.txt#[00m
#[00mbatmsjf.cpp#[00m #[00mphilos2.txt#[00m #[00mreawriter4.cpp#[00m
#[00mbatmsjf.dat#[00m #[00mphilos3.txt#[00m #[00mreawriter.cpp#[00m
#[00mbatmsjf.txt#[00m #[00mphilos.cpp#[00m #[00mreawriters.dat#[00m
#[m#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ clear
#[H#[2J#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ ./psim3c philoscw.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 philoscw.txt
Psim3 project: Concurrent Philosophers Problem Circular Wait
Simulation date: Tue Jul 9 20:19:54 2013
Concurrent Philosophers Circular Wait created
Philosopher0 created at 0
Philosopher1 created at 0
Philosopher2 created at 0
Philosopher3 created at 0
Philosopher4 created at 0
Philosopher0 thinking interval = 2.61518
Philosopher1 thinking interval = 36.3501
Philosopher2 thinking interval = 51.1848
Philosopher3 thinking interval = 3.90558
Philosopher4 thinking interval = 8.29805
Philosopher0 attempting CS at: 2.61518
-------------------------------------------------------------
fork4 % usage: 0.632073 avg num items used: 1
% of time spent in res usage: 0.632073
% of time spent waiting: 0.234163
-------------------------------------------------------------
-------------------------------------------------------------
fork3 % usage: 0.580245 avg num items used: 1
% of time spent in res usage: 0.580245
% of time spent waiting: 0.170316
-------------------------------------------------------------
-------------------------------------------------------------
fork2 % usage: 0.513805 avg num items used: 1
% of time spent in res usage: 0.513805
% of time spent waiting: 0.28587
-------------------------------------------------------------
-------------------------------------------------------------
fork1 % usage: 0.64489 avg num items used: 1
% of time spent in res usage: 0.64489
% of time spent waiting: 0.214496
-------------------------------------------------------------
-------------------------------------------------------------
fork0 % usage: 0.811469 avg num items used: 1
% of time spent in res usage: 0.811469
% of time spent waiting: 0.420307
-------------------------------------------------------------
Number of eating cycles phil 0 = 8
Total waiting interval to eat phil 0 = 101.17
Number of eating cycles phil 1 = 5
Total waiting interval to eat phil 1 = 79.3788
Number of eating cycles phil 2 = 6
Total waiting interval to eat phil 2 = 51.1304
Number of eating cycles phil 3 = 7
Total waiting interval to eat phil 3 = 13.298
Number of eating cycles phil 4 = 9
Total waiting interval to eat phil 4 = 103.811
Average interval waiting to eat: 69.7577
--------------------------------------------------
End of simulation Concurrent Philosophers Problem Circular Wait Tue Jul 9 20:19:54 2013
#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ clear
#[H#[2J#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ d##[K./psim3x ##[K##[Kc philoscw.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 philoscw.##[K2.txt
Psim3 project: Concurrent Philosophers Problem Circular Wait
Simulation date: Tue Jul 9 20:20:52 2013
Concurrent Philosophers Circular Wait created
Philosopher0 created at 0
Philosopher1 created at 0
Philosopher2 created at 0
Philosopher3 created at 0
Philosopher4 created at 0
Philosopher0 thinking interval = 14.1498
Philosopher1 thinking interval = 9.58654
Philosopher2 thinking interval = 13.0249
Philosopher4 thinking interval = 0.168752
Philosopher3 thinking interval = 13.4001
Philosopher4 attempting CS at: 0.168752
-------------------------------------------------------------
fork4 % usage: 0.593486 avg num items used: 1
% of time spent in res usage: 0.593486
% of time spent waiting: 0.270576
-------------------------------------------------------------
-------------------------------------------------------------
fork3 % usage: 0.784031 avg num items used: 1
% of time spent in res usage: 0.784031
% of time spent waiting: 0.287356
-------------------------------------------------------------
-------------------------------------------------------------
fork2 % usage: 0.744413 avg num items used: 1
% of time spent in res usage: 0.744413
% of time spent waiting: 0.305216
-------------------------------------------------------------
-------------------------------------------------------------
fork1 % usage: 0.790898 avg num items used: 1
% of time spent in res usage: 0.790898
% of time spent waiting: 0.298654
-------------------------------------------------------------
-------------------------------------------------------------
fork0 % usage: 0.879005 avg num items used: 1
% of time spent in res usage: 0.879005
% of time spent waiting: 0.50522
-------------------------------------------------------------
Number of eating cycles phil 0 = 4
Total waiting interval to eat phil 0 = 72.0529
Number of eating cycles phil 1 = 8
Total waiting interval to eat phil 1 = 86.3792
Number of eating cycles phil 2 = 5
Total waiting interval to eat phil 2 = 63.3861
Number of eating cycles phil 3 = 7
Total waiting interval to eat phil 3 = 80.5026
Number of eating cycles phil 4 = 9
Total waiting interval to eat phil 4 = 130.935
Average interval waiting to eat: 86.6511
--------------------------------------------------
End of simulation Concurrent Philosophers Problem Circular Wait Tue Jul 9 20:20:52 2013
#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ clear
#[H#[2J#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ ./psim3c philoscw.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 philoscw.##[K3.txt
Psim3 project: Concurrent Philosophers Problem Circular Wait
Simulation date: Tue Jul 9 20:21:13 2013
Concurrent Philosophers Circular Wait created
Philosopher0 created at 0
Philosopher1 created at 0
Philosopher2 created at 0
Philosopher3 created at 0
Philosopher4 created at 0
Philosopher0 thinking interval = 21.1013
Philosopher1 thinking interval = 7.37266
Philosopher2 thinking interval = 2.88714
Philosopher3 thinking interval = 6.44385
Philosopher4 thinking interval = 4.53386
Philosopher2 attempting CS at: 2.88714
Philosopher0 attempting CS at: 238.725
Philosopher0 requesting left fork at: 239.225
-------------------------------------------------------------
fork4 % usage: 0.536131 avg num items used: 1
% of time spent in res usage: 0.536131
% of time spent waiting: 0.0511825
-------------------------------------------------------------
-------------------------------------------------------------
fork3 % usage: 0.574367 avg num items used: 1
% of time spent in res usage: 0.574367
% of time spent waiting: 0.0837188
-------------------------------------------------------------
-------------------------------------------------------------
fork2 % usage: 0.524719 avg num items used: 1
% of time spent in res usage: 0.524719
% of time spent waiting: 0.111445
-------------------------------------------------------------
-------------------------------------------------------------
fork1 % usage: 0.786227 avg num items used: 1
% of time spent in res usage: 0.786227
% of time spent waiting: 0.327559
-------------------------------------------------------------
-------------------------------------------------------------
fork0 % usage: 0.767227 avg num items used: 1
% of time spent in res usage: 0.767227
% of time spent waiting: 0.268049
-------------------------------------------------------------
Number of eating cycles phil 0 = 6
Total waiting interval to eat phil 0 = 90.1819
Number of eating cycles phil 1 = 8
Total waiting interval to eat phil 1 = 51.076
Number of eating cycles phil 2 = 4
Total waiting interval to eat phil 2 = 2
Number of eating cycles phil 3 = 9
Total waiting interval to eat phil 3 = 26.7711
Number of eating cycles phil 4 = 6
Total waiting interval to eat phil 4 = 56.9594
Average interval waiting to eat: 45.3977
--------------------------------------------------
End of simulation Concurrent Philosophers Problem Circular Wait Tue Jul 9 20:21:13 2013
#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ clear
#[H#[2J#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ nano philos.cpp
#[?1l#>#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ ./psim3x ##[K##[Kc philos.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| tee philosModified.txt
Psim3 project: Concurrent philosophers problem
Simulation date: Tue Jul 9 20:23:59 2013
Concurrent Philosophers created
Philosopher0 created at 0
Philosopher1 created at 0
Philosopher2 created at 0
Philosopher3 created at 0
Philosopher4 created at 0
Philosopher0 requesting left fork at: 0
Philosopher0 acquired left fork at 0
Philosopher1 requesting left fork at: 0
Philosopher1 acquired left fork at 0
Philosopher3 requesting left fork at: 0
Philosopher3 acquired left fork at 0
Philosopher2 requesting left fork at: 0
Philosopher2 acquired left fork at 0
Philosopher0 requesting right fork at: 0
Philosopher1 requesting right fork at: 0
Philosopher4 requesting left fork at: 0
Philosopher4 acquired left fork at 0
Philosopher3 requesting right fork at: 0
Philosopher2 requesting right fork at: 0
Philosopher4 requesting right fork at: 0
-------------------------------------------------------------
fork4 % usage: 0
-------------------------------------------------------------
-------------------------------------------------------------
fork3 % usage: 0
-------------------------------------------------------------
-------------------------------------------------------------
fork2 % usage: 0
-------------------------------------------------------------
-------------------------------------------------------------
fork1 % usage: 0
-------------------------------------------------------------
-------------------------------------------------------------
fork0 % usage: 0
-------------------------------------------------------------
--------------------------------------------------
End of simulation Concurrent philosophers problem Tue Jul 9 20:23:59 2013
#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ clear
#[H#[2J#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ nano philoshw.cpp
#[?1l#>#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ ./psim3c philoshw.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 philoshw.##[KModified.txt
Psim3 project: Concurrent Philosophers - Hold & Wait
Simulation date: Tue Jul 9 20:25:40 2013
creating fork0
creating fork1
creating fork2
creating fork3
creating fork4
Concurrent Philosophers Hold & Wait created
Philosopher0 created with 15.45 9.5
Philosopher1 created with 25.45 19.5
Philosopher2 created with 65.45 35.5
Philosopher3 created with 20.45 5.5
Philosopher4 created with 7.45 12.5
Philosopher2 think interval = 71.9825
Philosopher1 think interval = 24.4297
Philosopher0 think interval = 16.9921
Philosopher3 think interval = 19.6302
Philosopher4 think interval = 8.19358
-------------------------------------------------------------
Mutex % usage: 0
-------------------------------------------------------------
-------------------------------------------------------------
fork4 % usage: 0.651499 avg num items used: 1
% of time spent in res usage: 0.651499
-------------------------------------------------------------
-------------------------------------------------------------
fork3 % usage: 0.462515 avg num items used: 1
% of time spent in res usage: 0.462515
-------------------------------------------------------------
-------------------------------------------------------------
fork2 % usage: 0.610154 avg num items used: 1
% of time spent in res usage: 0.610154
-------------------------------------------------------------
-------------------------------------------------------------
fork1 % usage: 0.620995 avg num items used: 1
% of time spent in res usage: 0.620995
-------------------------------------------------------------
-------------------------------------------------------------
fork0 % usage: 0.826116 avg num items used: 1
% of time spent in res usage: 0.826116
-------------------------------------------------------------
Number of eat cycles Philosopher00 = 8
Total waiting time to eat Philosopher00 = 45.2336
Number of eat cycles Philosopher11 = 4
Total waiting time to eat Philosopher11 = 62.1303
Number of eat cycles Philosopher22 = 2
Total waiting time to eat Philosopher22 = 9.45542
Number of eat cycles Philosopher33 = 7
Total waiting time to eat Philosopher33 = 76.105
Number of eat cycles Philosopher44 = 11
Total waiting time to eat Philosopher44 = 37.5629
Average time waiting to eat: 46.0974
--------------------------------------------------
End of simulation Concurrent Philosophers - Hold & Wait Tue Jul 9 20:25:40 2013
#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ clear
#[H#[2J#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ nano philoscw.cpp
#[?1l#>#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ ./psim3c philoscw.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 philoscwModified.txt
Psim3 project: Concurrent Philosophers Problem Circular Wait
Simulation date: Tue Jul 9 20:26:55 2013
Concurrent Philosophers Circular Wait created
Philosopher0 created at 0
Philosopher1 created at 0
Philosopher2 created at 0
Philosopher3 created at 0
Philosopher4 created at 0
Philosopher0 thinking interval = 4.18779
Philosopher1 thinking interval = 8.17766
Philosopher2 thinking interval = 5.37377
Philosopher3 thinking interval = 45.2182
Philosopher4 thinking interval = 17.5569
-------------------------------------------------------------
fork4 % usage: 0.801396 avg num items used: 1
% of time spent in res usage: 0.801396
% of time spent waiting: 0.371017
-------------------------------------------------------------
-------------------------------------------------------------
fork3 % usage: 0.923135 avg num items used: 1
% of time spent in res usage: 0.923135
% of time spent waiting: 0.534555
-------------------------------------------------------------
-------------------------------------------------------------
fork2 % usage: 0.870512 avg num items used: 1
% of time spent in res usage: 0.870512
% of time spent waiting: 0.469977
-------------------------------------------------------------
-------------------------------------------------------------
fork1 % usage: 0.644891 avg num items used: 1
% of time spent in res usage: 0.644891
% of time spent waiting: 0.139954
-------------------------------------------------------------
-------------------------------------------------------------
fork0 % usage: 0.909789 avg num items used: 1
% of time spent in res usage: 0.909789
% of time spent waiting: 0.752047
-------------------------------------------------------------
Number of eating cycles phil 0 = 3
Total waiting interval to eat phil 0 = 84.2897
Number of eating cycles phil 1 = 5
Total waiting interval to eat phil 1 = 138.958
Number of eating cycles phil 2 = 6
Total waiting interval to eat phil 2 = 93.8562
Number of eating cycles phil 3 = 4
Total waiting interval to eat phil 3 = 149.836
Number of eating cycles phil 4 = 3
Total waiting interval to eat phil 4 = 42.4751
Average interval waiting to eat: 101.883
--------------------------------------------------
End of simulation Concurrent Philosophers Problem Circular Wait Tue Jul 9 20:26:55 2013
#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ clear
#[H#[2J#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ exit
exit
Script done on Tue 09 Jul 2013 08:27:02 PM EDT
Department of Computer Science
Operating Systems CS3530/01
Assignment # 5 / Deadlock
Dalibor Labudovic
07/09/12013
Initial Problem Statement:
Study of Deadlocks with the Five Philosophers Problem.
This assignment involves observation of general behavior of a system with deadlock situations and solutions. Computation of some relevant performance metrics.
There are three models implemented in C++ using Psim3 package:
"philos.cpp", "philoshw.cpp", and "philoscw.cpp".
The first model always deadlocks.
The second model applies the dis-allowance of the hold and wait condition as a solution to deadlock.
The third model applies dis-allowance of the circular wait condition as a solution to deadlock.
Copy the model source C++ files from the system directory on the CS3 server, then compile, and link to create the executable program.
Run the program at least three times. Change the average parameter for the eating and thinking periods, and compare results.
Write a report describing the characteristics of the operating system modeled. Use the usual guidelines for structuring the report.
At the end of your report, include at the end of the report your answers to the following questions:
* What aspect of an operating system is the model representing?
* What performance measures does the model compute?
* What is noticeable in the dynamic behavior of the system?
* After changing some of the parameters in the model (the workload) and recompiling. What changes in the results do you notice?
* What other performance measures can this model compute?
As usual, use the guidelines on the course web page for structuring your report.
Summary and purpose of the assignment activity:
The purpose of this assignment activity is to experience the results of a dead lock and also run two simulation to solve the deadlock occurrence. With these simulation run, we are able to better understand the deadlock occurrence and we will have a deeper meaning of how to go about solving the issue.
To summarize the assignment activity, deadlock occurrence is worse then starvation because it ties up resources . There are two ways to solve deadlock occurrence and they are to dis-allow hold and wait conditions and to dis-allow circular wait conditions.
Detail description of the solution and used in the project:
In this report the assignment had three simulation models. One is the deadlock occurrence, where there is a deadlock and none of the philosophers are able to think nor eat because of their required resources are not available. For this first deadlock occurrence, we are to run the simulation three times, then modified a parameter within the simulation program to compare the differences.
The second simulation model is the dis-allowance of the hold and wait condition to solve the deadlock, again we are to run this simulation program three times and the fourth time we are to modify a parameter within the program, then compare and contrast the results.
Third simulation model is the dis-allowance of the circular wait condition to solve deadlock, again we are run this simulation program three times and the fourth time, we are to modify a parameter within the program, then compare and contrast the results.
Table of results:
Philos run 1:
fork4 % usage: 0
fork3 % usage: 0
fork2 % usage: 0
fork1 % usage: 0
fork0 % usage: 0
Philos run 2:
fork4 % usage: 0
fork3 % usage: 0
fork2 % usage: 0
fork1 % usage: 0
fork0 % usage: 0
Philos run 3:
fork4 % usage: 0
fork3 % usage: 0
fork2 % usage: 0
fork1 % usage: 0
fork0 % usage: 0
Philos modified run:
fork4 % usage: 0
fork3 % usage: 0
fork2 % usage: 0
fork1 % usage: 0
fork0 % usage: 0
Phioscw run 1:
fork4 % usage: 0.632073 avg num items used: 1
% of time spent in res usage: 0.632073
% of time spent waiting: 0.234163
fork3 % usage: 0.580245 avg num items used: 1
% of time spent in res usage: 0.580245
% of time spent waiting: 0.170316
fork2 % usage: 0.513805 avg num items used: 1
% of time spent in res usage: 0.513805
% of time spent waiting: 0.28587
fork1 % usage: 0.64489 avg num items used: 1
% of time spent in res usage: 0.64489
% of time spent waiting: 0.214496
fork0 % usage: 0.811469 avg num items used: 1
% of time spent in res usage: 0.811469
% of time spent waiting: 0.420307
-------------------------------------------------------------
Number of eating cycles phil 0 = 8
Total waiting interval to eat phil 0 = 101.17
Number of eating cycles phil 1 = 5
Total waiting interval to eat phil 1 = 79.3788
Number of eating cycles phil 2 = 6
Total waiting interval to eat phil 2 = 51.1304
Number of eating cycles phil 3 = 7
Total waiting interval to eat phil 3 = 13.298
Number of eating cycles phil 4 = 9
Total waiting interval to eat phil 4 = 103.811
Average interval waiting to eat: 69.7577
Philoscw run 2:
fork4 % usage: 0.593486 avg num items used: 1
% of time spent in res usage: 0.593486
% of time spent waiting: 0.270576
fork3 % usage: 0.784031 avg num items used: 1
% of time spent in res usage: 0.784031
% of time spent waiting: 0.287356
fork2 % usage: 0.744413 avg num items used: 1
% of time spent in res usage: 0.744413
% of time spent waiting: 0.305216
fork1 % usage: 0.790898 avg num items used: 1
% of time spent in res usage: 0.790898
% of time spent waiting: 0.298654
fork0 % usage: 0.879005 avg num items used: 1
% of time spent in res usage: 0.879005
% of time spent waiting: 0.50522
-------------------------------------------------------------
Number of eating cycles phil 0 = 4
Total waiting interval to eat phil 0 = 72.0529
Number of eating cycles phil 1 = 8
Total waiting interval to eat phil 1 = 86.3792
Number of eating cycles phil 2 = 5
Total waiting interval to eat phil 2 = 63.3861
Number of eating cycles phil 3 = 7
Total waiting interval to eat phil 3 = 80.5026
Number of eating cycles phil 4 = 9
Total waiting interval to eat phil 4 = 130.935
Average interval waiting to eat: 86.6511
Philoscw run 3:
fork4 % usage: 0.536131 avg num items used: 1
% of time spent in res usage: 0.536131
% of time spent waiting: 0.0511825
fork3 % usage: 0.574367 avg num items used: 1
% of time spent in res usage: 0.574367
% of time spent waiting: 0.0837188
fork2 % usage: 0.524719 avg num items used: 1
% of time spent in res usage: 0.524719
% of time spent waiting: 0.111445
fork1 % usage: 0.786227 avg num items used: 1
% of time spent in res usage: 0.786227
% of time spent waiting: 0.327559
fork0 % usage: 0.767227 avg num items used: 1
% of time spent in res usage: 0.767227
% of time spent waiting: 0.268049
-------------------------------------------------------------
Number of eating cycles phil 0 = 6
Total waiting interval to eat phil 0 = 90.1819
Number of eating cycles phil 1 = 8
Total waiting interval to eat phil 1 = 51.076
Number of eating cycles phil 2 = 4
Total waiting interval to eat phil 2 = 2
Number of eating cycles phil 3 = 9
Total waiting interval to eat phil 3 = 26.7711
Number of eating cycles phil 4 = 6
Total waiting interval to eat phil 4 = 56.9594
Average interval waiting to eat: 45.3977
Philoscw modified run:
fork4 % usage: 0.801396 avg num items used: 1
% of time spent in res usage: 0.801396
% of time spent waiting: 0.371017
fork3 % usage: 0.923135 avg num items used: 1
% of time spent in res usage: 0.923135
% of time spent waiting: 0.534555
fork2 % usage: 0.870512 avg num items used: 1
% of time spent in res usage: 0.870512
% of time spent waiting: 0.469977
fork1 % usage: 0.644891 avg num items used: 1
% of time spent in res usage: 0.644891
% of time spent waiting: 0.139954
fork0 % usage: 0.909789 avg num items used: 1
% of time spent in res usage: 0.909789
% of time spent waiting: 0.752047
-------------------------------------------------------------
Number of eating cycles phil 0 = 3
Total waiting interval to eat phil 0 = 84.2897
Number of eating cycles phil 1 = 5
Total waiting interval to eat phil 1 = 138.958
Number of eating cycles phil 2 = 6
Total waiting interval to eat phil 2 = 93.8562
Number of eating cycles phil 3 = 4
Total waiting interval to eat phil 3 = 149.836
Number of eating cycles phil 4 = 3
Total waiting interval to eat phil 4 = 42.4751
Average interval waiting to eat: 101.883
Philoshw run 1:
Mutex % usage: 0
fork4 % usage: 0.672824 avg num items used: 1
% of time spent in res usage: 0.672824
fork3 % usage: 0.431571 avg num items used: 1
% of time spent in res usage: 0.431571
fork2 % usage: 0.581972 avg num items used: 1
% of time spent in res usage: 0.581972
fork1 % usage: 0.613724 avg num items used: 1
% of time spent in res usage: 0.613724
fork0 % usage: 0.815491 avg num items used: 1
% of time spent in res usage: 0.815491
-------------------------------------------------------------
Number of eat cycles Philosopher00 = 8
Total waiting time to eat Philosopher00 = 50.804
Number of eat cycles Philosopher11 = 4
Total waiting time to eat Philosopher11 = 33.7411
Number of eat cycles Philosopher22 = 3
Total waiting time to eat Philosopher22 = 19.6415
Number of eat cycles Philosopher33 = 7
Total waiting time to eat Philosopher33 = 43.234
Number of eat cycles Philosopher44 = 11
Total waiting time to eat Philosopher44 = 36.6998
Average time waiting to eat: 36.8241
Philoshw run 2:
Mutex % usage: 0
fork4 % usage: 0.567401 avg num items used: 1
% of time spent in res usage: 0.567401
fork3 % usage: 0.545788 avg num items used: 1
% of time spent in res usage: 0.545788
fork2 % usage: 0.672567 avg num items used: 1
% of time spent in res usage: 0.672567
fork1 % usage: 0.548489 avg num items used: 1
% of time spent in res usage: 0.548489
fork0 % usage: 0.745428 avg num items used: 1
% of time spent in res usage: 0.745428
Number of eat cycles Philosopher00 = 9
Total waiting time to eat Philosopher00 = 23.5328
Number of eat cycles Philosopher11 = 3
Total waiting time to eat Philosopher11 = 48.4071
Number of eat cycles Philosopher22 = 3
Total waiting time to eat Philosopher22 = 0.553999
Number of eat cycles Philosopher33 = 7
Total waiting time to eat Philosopher33 = 90.8342
Number of eat cycles Philosopher44 = 9
Total waiting time to eat Philosopher44 = 55.8926
Average time waiting to eat: 43.8442
Philoshw run 3:
Mutex % usage: 0
fork4 % usage: 0.625626 avg num items used: 1
% of time spent in res usage: 0.625626
fork3 % usage: 0.444857 avg num items used: 1
% of time spent in res usage: 0.444857
fork2 % usage: 0.647479 avg num items used: 1
% of time spent in res usage: 0.647479
fork1 % usage: 0.555536 avg num items used: 1
% of time spent in res usage: 0.555536
fork0 % usage: 0.77772 avg num items used: 1
% of time spent in res usage: 0.77772
-------------------------------------------------------------
Number of eat cycles Philosopher00 = 7
Total waiting time to eat Philosopher00 = 44.4612
Number of eat cycles Philosopher11 = 5
Total waiting time to eat Philosopher11 = 38.8937
Number of eat cycles Philosopher22 = 2
Total waiting time to eat Philosopher22 = 12.2789
Number of eat cycles Philosopher33 = 6
Total waiting time to eat Philosopher33 = 86.2948
Number of eat cycles Philosopher44 = 11
Total waiting time to eat Philosopher44 = 26.7041
Average time waiting to eat: 41.7265
Philoshw modified run:
Mutex % usage: 0
fork4 % usage: 0.651499 avg num items used: 1
% of time spent in res usage: 0.651499
fork3 % usage: 0.462515 avg num items used: 1
% of time spent in res usage: 0.462515
fork2 % usage: 0.610154 avg num items used: 1
% of time spent in res usage: 0.610154
fork1 % usage: 0.620995 avg num items used: 1
% of time spent in res usage: 0.620995
fork0 % usage: 0.826116 avg num items used: 1
% of time spent in res usage: 0.826116
-------------------------------------------------------------
Number of eat cycles Philosopher00 = 8
Total waiting time to eat Philosopher00 = 45.2336
Number of eat cycles Philosopher11 = 4
Total waiting time to eat Philosopher11 = 62.1303
Number of eat cycles Philosopher22 = 2
Total waiting time to eat Philosopher22 = 9.45542
Number of eat cycles Philosopher33 = 7
Total waiting time to eat Philosopher33 = 76.105
Number of eat cycles Philosopher44 = 11
Total waiting time to eat Philosopher44 = 37.5629
Average time waiting to eat: 46.0974
Comments and Conclusion:
Conclusion thoughts on this assignment is the bitterness of not having a graphical visualization to compare the differences between the dis-allowance hold and wait and circular wait conditions. I am glad we were able to run these simulation model to better understand the occurrence of deadlock and the solutions to solve the deadlock occurrence.
Questions and Answers:
1. What aspect of an operating system is the model representing?
This model represents the resources management of the OS, the processes require certain resources and they compete or collaborate for those resources. A deadlock simulation model is an overview of what is possible when more than one process requires access to a single resource.
2. What performance measures does the model compute?
This simulation model compute the average time waiting to eat for each philosopher.
3. What is noticeable in the dynamic behavior of the system?
The noticeable behavior of the system in a dynamic way was when the parameter was changed in the philoshw modified simulation run, with the time mean think time for philosopher 2 from 45 to 65, the change on the average time waiting to eat increased but only slightly. My expectations were to have a increased average wait time to eat by dramatically.
4. After changing some of the parameters in the model (the workload) and recompiling. What changes in the results do you notice?
Surprisingly, the changes were saddle and not at all dramatic, the changed parameters where usually increased thinking time and the average waiting time to each mostly stayed close to the average time from the three previous runs or increased only slightly. In the future my experiments and simulation runs would be better analyzed when done with some graphical structure to better understand the comparison between the two model runs.
5. What other performance measures can this model compute?
Other performance measures this model can compute are the total waiting time for each philosopher, fork usage and mutex usage.
Script:
Script started on Tue 09 Jul 2013 08:14:43 PM EDT
#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ /##[K/##[K./psim3c philos.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 philos.txt
Psim3 project: Concurrent philosophers problem
Simulation date: Tue Jul 9 20:15:49 2013
-------------------------------------------------------------
fork4 % usage: 0
-------------------------------------------------------------
-------------------------------------------------------------
fork3 % usage: 0
-------------------------------------------------------------
-------------------------------------------------------------
fork2 % usage: 0
-------------------------------------------------------------
-------------------------------------------------------------
fork1 % usage: 0
-------------------------------------------------------------
-------------------------------------------------------------
fork0 % usage: 0
-------------------------------------------------------------
--------------------------------------------------
End of simulation Concurrent philosophers problem Tue Jul 9 20:15:49 2013
#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ clear
#[H#[2J#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ ./psim3c philos.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 philos2.txt
Psim3 project: Concurrent philosophers problem
Simulation date: Tue Jul 9 20:16:57 2013
-------------------------------------------------------------
fork4 % usage: 0
fork3 % usage: 0
fork2 % usage: 0
fork1 % usage: 0
fork0 % usage: 0
End of simulation Concurrent philosophers problem Tue Jul 9 20:16:57 2013
#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ clear
#[H#[2J#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ ./psim3c philos.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 philos3.txt
Psim3 project: Concurrent philosophers problem
Simulation date: Tue Jul 9 20:17:35 2013
-------------------------------------------------------------
fork4 % usage: 0
-------------------------------------------------------------
-------------------------------------------------------------
fork3 % usage: 0
-------------------------------------------------------------
-------------------------------------------------------------
fork2 % usage: 0
-------------------------------------------------------------
-------------------------------------------------------------
fork1 % usage: 0
-------------------------------------------------------------
-------------------------------------------------------------
fork0 % usage: 0
-------------------------------------------------------------
--------------------------------------------------
End of simulation Concurrent philosophers problem Tue Jul 9 20:17:35 2013
#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ cler##[Kar
#[H#[2J#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ ./psim3c philoshw.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 |te##[K##[K tee philoshw.c##[Ktxt
Psim3 project: Concurrent Philosophers - Hold & Wait
Simulation date: Tue Jul 9 20:18:09 2013
creating fork0
creating fork1
creating fork2
creating fork3
creating fork4
Concurrent Philosophers Hold & Wait created
Philosopher0 created with 15.45 9.5
Philosopher1 created with 25.45 19.5
Philosopher2 created with 45.45 35.5
Philosopher3 created with 20.45 5.5
Philosopher4 created with 7.45 12.5
Philosopher0 think interval = 17.1968
Philosopher1 think interval = 32.4803
Philosopher2 think interval = 50.5885
Philosopher3 think interval = 26.0991
Philosopher4 think interval = 8.29229
-------------------------------------------------------------
Mutex % usage: 0
-------------------------------------------------------------
-------------------------------------------------------------
fork4 % usage: 0.672824 avg num items used: 1
% of time spent in res usage: 0.672824
-------------------------------------------------------------
-------------------------------------------------------------
fork3 % usage: 0.431571 avg num items used: 1
% of time spent in res usage: 0.431571
-------------------------------------------------------------
-------------------------------------------------------------
fork2 % usage: 0.581972 avg num items used: 1
% of time spent in res usage: 0.581972
-------------------------------------------------------------
-------------------------------------------------------------
fork1 % usage: 0.613724 avg num items used: 1
% of time spent in res usage: 0.613724
-------------------------------------------------------------
-------------------------------------------------------------
fork0 % usage: 0.815491 avg num items used: 1
% of time spent in res usage: 0.815491
-------------------------------------------------------------
Number of eat cycles Philosopher00 = 8
Total waiting time to eat Philosopher00 = 50.804
Number of eat cycles Philosopher11 = 4
Total waiting time to eat Philosopher11 = 33.7411
Number of eat cycles Philosopher22 = 3
Total waiting time to eat Philosopher22 = 19.6415
Number of eat cycles Philosopher33 = 7
Total waiting time to eat Philosopher33 = 43.234
Number of eat cycles Philosopher44 = 11
Total waiting time to eat Philosopher44 = 36.6998
Average time waiting to eat: 36.8241
--------------------------------------------------
End of simulation Concurrent Philosophers - Hold & Wait Tue Jul 9 20:18:09 2013
#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ clear
#[H#[2J#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ ./psim3c philoshw.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##[K./a.out | tee ohi##[K##[K##[Kphiloshw.##[K3##[K2.txt
Psim3 project: Concurrent Philosophers - Hold & Wait
Simulation date: Tue Jul 9 20:18:40 2013
creating fork0
creating fork1
creating fork2
creating fork3
creating fork4
Concurrent Philosophers Hold & Wait created
Philosopher0 created with 15.45 9.5
Philosopher1 created with 25.45 19.5
Philosopher2 created with 45.45 35.5
Philosopher3 created with 20.45 5.5
Philosopher4 created with 7.45 12.5
Philosopher0 think interval = 15.2106
Philosopher1 think interval = 22.0463
Philosopher2 think interval = 44.7459
Philosopher3 think interval = 17.715
Philosopher4 think interval = 7.33458
-------------------------------------------------------------
Mutex % usage: 0
-------------------------------------------------------------
-------------------------------------------------------------
fork4 % usage: 0.567401 avg num items used: 1
% of time spent in res usage: 0.567401
-------------------------------------------------------------
-------------------------------------------------------------
fork3 % usage: 0.545788 avg num items used: 1
% of time spent in res usage: 0.545788
-------------------------------------------------------------
-------------------------------------------------------------
fork2 % usage: 0.672567 avg num items used: 1
% of time spent in res usage: 0.672567
-------------------------------------------------------------
-------------------------------------------------------------
fork1 % usage: 0.548489 avg num items used: 1
% of time spent in res usage: 0.548489
-------------------------------------------------------------
-------------------------------------------------------------
fork0 % usage: 0.745428 avg num items used: 1
% of time spent in res usage: 0.745428
-------------------------------------------------------------
Number of eat cycles Philosopher00 = 9
Total waiting time to eat Philosopher00 = 23.5328
Number of eat cycles Philosopher11 = 3
Total waiting time to eat Philosopher11 = 48.4071
Number of eat cycles Philosopher22 = 3
Total waiting time to eat Philosopher22 = 0.553999
Number of eat cycles Philosopher33 = 7
Total waiting time to eat Philosopher33 = 90.8342
Number of eat cycles Philosopher44 = 9
Total waiting time to eat Philosopher44 = 55.8926
Average time waiting to eat: 43.8442
--------------------------------------------------
End of simulation Concurrent Philosophers - Hold & Wait Tue Jul 9 20:18:40 2013
#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ clear
#[H#[2J#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ ./psim3c philoshw.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 o##[Kphiloshw.##[K3.txt
Psim3 project: Concurrent Philosophers - Hold & Wait
Simulation date: Tue Jul 9 20:19:22 2013
creating fork0
creating fork1
creating fork2
creating fork3
creating fork4
Concurrent Philosophers Hold & Wait created
Philosopher0 created with 15.45 9.5
Philosopher1 created with 25.45 19.5
Philosopher2 created with 45.45 35.5
Philosopher3 created with 20.45 5.5
Philosopher4 created with 7.45 12.5
Philosopher0 think interval = 14.8496
Philosopher4 think interval = 5.94668
Philosopher3 think interval = 19.6552
Philosopher2 think interval = 36.2787
Philosopher1 think interval = 24.4609
-------------------------------------------------------------
Mutex % usage: 0
-------------------------------------------------------------
-------------------------------------------------------------
fork4 % usage: 0.625626 avg num items used: 1
% of time spent in res usage: 0.625626
-------------------------------------------------------------
-------------------------------------------------------------
fork3 % usage: 0.444857 avg num items used: 1
% of time spent in res usage: 0.444857
-------------------------------------------------------------
-------------------------------------------------------------
fork2 % usage: 0.647479 avg num items used: 1
% of time spent in res usage: 0.647479
-------------------------------------------------------------
-------------------------------------------------------------
fork1 % usage: 0.555536 avg num items used: 1
% of time spent in res usage: 0.555536
-------------------------------------------------------------
-------------------------------------------------------------
fork0 % usage: 0.77772 avg num items used: 1
% of time spent in res usage: 0.77772
-------------------------------------------------------------
Number of eat cycles Philosopher00 = 7
Total waiting time to eat Philosopher00 = 44.4612
Number of eat cycles Philosopher11 = 5
Total waiting time to eat Philosopher11 = 38.8937
Number of eat cycles Philosopher22 = 2
Total waiting time to eat Philosopher22 = 12.2789
Number of eat cycles Philosopher33 = 6
Total waiting time to eat Philosopher33 = 86.2948
Number of eat cycles Philosopher44 = 11
Total waiting time to eat Philosopher44 = 26.7041
Average time waiting to eat: 41.7265
--------------------------------------------------
End of simulation Concurrent Philosophers - Hold & Wait Tue Jul 9 20:19:22 2013
#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ clear
#[H#[2J#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ ls
#[00m#[00;32ma.out#[00m #[00mComplexNum.c#[00m #[00mphiloscw.cpp#[00m #[00mreawriter.txt#[00m
#[00mbacmfcfs.txt#[00m #[00;34mcomp_mod#[00m #[00mphilos.dat#[00m #[00mresources1.dat#[00m
#[00mbasic_lib.c#[00m #[00mconsprod2.txt#[00m #[00mphiloshw2.txt#[00m #[00mresources2.dat#[00m
#[00mbasic_lib.h#[00m #[00mconsprod.cpp#[00m #[00mphiloshw3.txt#[00m #[00mresources.dat#[00m
#[00mbatchmio1.dat#[00m #[00mconsprod.dat#[00m #[00mphiloshw.cpp#[00m #[00mscriptassignment2.txt#[00m
#[00mbatchmio2.dat#[00m #[00mconsprod.txt#[00m #[00mphiloshw.dat#[00m #[00mscriptassignment4.txt#[00m
#[00mbatchmio.cpp#[00m #[00mdistance.c#[00m #[00mphiloshw.txt#[00m #[00mscriptassignment5.txt#[00m
#[00mbatchmio.dat#[00m #[00mfreefall.c#[00m #[00mphilos.txt#[00m #[00mstrddev.c#[00m
#[00mbatmfcfs.cpp#[00m #[00mheight.c#[00m #[00;32mpsim3c#[00m #[00mtsmult.cpp#[00m
#[00mbatmfcfs.dat#[00m #[00;34mmyos#[00m #[00mrainfall.c#[00m #[00mtsmult.dat#[00m
#[00mbatmfcfs.txt#[00m #[00;32mmysession1.txt#[00m #[00mreawriter2.txt#[00m #[00mtsmult.txt#[00m
#[00mbatmsjf.cpp#[00m #[00mphilos2.txt#[00m #[00mreawriter4.cpp#[00m
#[00mbatmsjf.dat#[00m #[00mphilos3.txt#[00m #[00mreawriter.cpp#[00m
#[00mbatmsjf.txt#[00m #[00mphilos.cpp#[00m #[00mreawriters.dat#[00m
#[m#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ clear
#[H#[2J#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ ./psim3c philoscw.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 philoscw.txt
Psim3 project: Concurrent Philosophers Problem Circular Wait
Simulation date: Tue Jul 9 20:19:54 2013
Concurrent Philosophers Circular Wait created
Philosopher0 created at 0
Philosopher1 created at 0
Philosopher2 created at 0
Philosopher3 created at 0
Philosopher4 created at 0
Philosopher0 thinking interval = 2.61518
Philosopher1 thinking interval = 36.3501
Philosopher2 thinking interval = 51.1848
Philosopher3 thinking interval = 3.90558
Philosopher4 thinking interval = 8.29805
Philosopher0 attempting CS at: 2.61518
-------------------------------------------------------------
fork4 % usage: 0.632073 avg num items used: 1
% of time spent in res usage: 0.632073
% of time spent waiting: 0.234163
-------------------------------------------------------------
-------------------------------------------------------------
fork3 % usage: 0.580245 avg num items used: 1
% of time spent in res usage: 0.580245
% of time spent waiting: 0.170316
-------------------------------------------------------------
-------------------------------------------------------------
fork2 % usage: 0.513805 avg num items used: 1
% of time spent in res usage: 0.513805
% of time spent waiting: 0.28587
-------------------------------------------------------------
-------------------------------------------------------------
fork1 % usage: 0.64489 avg num items used: 1
% of time spent in res usage: 0.64489
% of time spent waiting: 0.214496
-------------------------------------------------------------
-------------------------------------------------------------
fork0 % usage: 0.811469 avg num items used: 1
% of time spent in res usage: 0.811469
% of time spent waiting: 0.420307
-------------------------------------------------------------
Number of eating cycles phil 0 = 8
Total waiting interval to eat phil 0 = 101.17
Number of eating cycles phil 1 = 5
Total waiting interval to eat phil 1 = 79.3788
Number of eating cycles phil 2 = 6
Total waiting interval to eat phil 2 = 51.1304
Number of eating cycles phil 3 = 7
Total waiting interval to eat phil 3 = 13.298
Number of eating cycles phil 4 = 9
Total waiting interval to eat phil 4 = 103.811
Average interval waiting to eat: 69.7577
--------------------------------------------------
End of simulation Concurrent Philosophers Problem Circular Wait Tue Jul 9 20:19:54 2013
#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ clear
#[H#[2J#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ d##[K./psim3x ##[K##[Kc philoscw.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 philoscw.##[K2.txt
Psim3 project: Concurrent Philosophers Problem Circular Wait
Simulation date: Tue Jul 9 20:20:52 2013
Concurrent Philosophers Circular Wait created
Philosopher0 created at 0
Philosopher1 created at 0
Philosopher2 created at 0
Philosopher3 created at 0
Philosopher4 created at 0
Philosopher0 thinking interval = 14.1498
Philosopher1 thinking interval = 9.58654
Philosopher2 thinking interval = 13.0249
Philosopher4 thinking interval = 0.168752
Philosopher3 thinking interval = 13.4001
Philosopher4 attempting CS at: 0.168752
-------------------------------------------------------------
fork4 % usage: 0.593486 avg num items used: 1
% of time spent in res usage: 0.593486
% of time spent waiting: 0.270576
-------------------------------------------------------------
-------------------------------------------------------------
fork3 % usage: 0.784031 avg num items used: 1
% of time spent in res usage: 0.784031
% of time spent waiting: 0.287356
-------------------------------------------------------------
-------------------------------------------------------------
fork2 % usage: 0.744413 avg num items used: 1
% of time spent in res usage: 0.744413
% of time spent waiting: 0.305216
-------------------------------------------------------------
-------------------------------------------------------------
fork1 % usage: 0.790898 avg num items used: 1
% of time spent in res usage: 0.790898
% of time spent waiting: 0.298654
-------------------------------------------------------------
-------------------------------------------------------------
fork0 % usage: 0.879005 avg num items used: 1
% of time spent in res usage: 0.879005
% of time spent waiting: 0.50522
-------------------------------------------------------------
Number of eating cycles phil 0 = 4
Total waiting interval to eat phil 0 = 72.0529
Number of eating cycles phil 1 = 8
Total waiting interval to eat phil 1 = 86.3792
Number of eating cycles phil 2 = 5
Total waiting interval to eat phil 2 = 63.3861
Number of eating cycles phil 3 = 7
Total waiting interval to eat phil 3 = 80.5026
Number of eating cycles phil 4 = 9
Total waiting interval to eat phil 4 = 130.935
Average interval waiting to eat: 86.6511
--------------------------------------------------
End of simulation Concurrent Philosophers Problem Circular Wait Tue Jul 9 20:20:52 2013
#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ clear
#[H#[2J#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ ./psim3c philoscw.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 philoscw.##[K3.txt
Psim3 project: Concurrent Philosophers Problem Circular Wait
Simulation date: Tue Jul 9 20:21:13 2013
Concurrent Philosophers Circular Wait created
Philosopher0 created at 0
Philosopher1 created at 0
Philosopher2 created at 0
Philosopher3 created at 0
Philosopher4 created at 0
Philosopher0 thinking interval = 21.1013
Philosopher1 thinking interval = 7.37266
Philosopher2 thinking interval = 2.88714
Philosopher3 thinking interval = 6.44385
Philosopher4 thinking interval = 4.53386
Philosopher2 attempting CS at: 2.88714
Philosopher0 attempting CS at: 238.725
Philosopher0 requesting left fork at: 239.225
-------------------------------------------------------------
fork4 % usage: 0.536131 avg num items used: 1
% of time spent in res usage: 0.536131
% of time spent waiting: 0.0511825
-------------------------------------------------------------
-------------------------------------------------------------
fork3 % usage: 0.574367 avg num items used: 1
% of time spent in res usage: 0.574367
% of time spent waiting: 0.0837188
-------------------------------------------------------------
-------------------------------------------------------------
fork2 % usage: 0.524719 avg num items used: 1
% of time spent in res usage: 0.524719
% of time spent waiting: 0.111445
-------------------------------------------------------------
-------------------------------------------------------------
fork1 % usage: 0.786227 avg num items used: 1
% of time spent in res usage: 0.786227
% of time spent waiting: 0.327559
-------------------------------------------------------------
-------------------------------------------------------------
fork0 % usage: 0.767227 avg num items used: 1
% of time spent in res usage: 0.767227
% of time spent waiting: 0.268049
-------------------------------------------------------------
Number of eating cycles phil 0 = 6
Total waiting interval to eat phil 0 = 90.1819
Number of eating cycles phil 1 = 8
Total waiting interval to eat phil 1 = 51.076
Number of eating cycles phil 2 = 4
Total waiting interval to eat phil 2 = 2
Number of eating cycles phil 3 = 9
Total waiting interval to eat phil 3 = 26.7711
Number of eating cycles phil 4 = 6
Total waiting interval to eat phil 4 = 56.9594
Average interval waiting to eat: 45.3977
--------------------------------------------------
End of simulation Concurrent Philosophers Problem Circular Wait Tue Jul 9 20:21:13 2013
#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ clear
#[H#[2J#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ nano philos.cpp
#[?1l#>#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ ./psim3x ##[K##[Kc philos.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| tee philosModified.txt
Psim3 project: Concurrent philosophers problem
Simulation date: Tue Jul 9 20:23:59 2013
Concurrent Philosophers created
Philosopher0 created at 0
Philosopher1 created at 0
Philosopher2 created at 0
Philosopher3 created at 0
Philosopher4 created at 0
Philosopher0 requesting left fork at: 0
Philosopher0 acquired left fork at 0
Philosopher1 requesting left fork at: 0
Philosopher1 acquired left fork at 0
Philosopher3 requesting left fork at: 0
Philosopher3 acquired left fork at 0
Philosopher2 requesting left fork at: 0
Philosopher2 acquired left fork at 0
Philosopher0 requesting right fork at: 0
Philosopher1 requesting right fork at: 0
Philosopher4 requesting left fork at: 0
Philosopher4 acquired left fork at 0
Philosopher3 requesting right fork at: 0
Philosopher2 requesting right fork at: 0
Philosopher4 requesting right fork at: 0
-------------------------------------------------------------
fork4 % usage: 0
-------------------------------------------------------------
-------------------------------------------------------------
fork3 % usage: 0
-------------------------------------------------------------
-------------------------------------------------------------
fork2 % usage: 0
-------------------------------------------------------------
-------------------------------------------------------------
fork1 % usage: 0
-------------------------------------------------------------
-------------------------------------------------------------
fork0 % usage: 0
-------------------------------------------------------------
--------------------------------------------------
End of simulation Concurrent philosophers problem Tue Jul 9 20:23:59 2013
#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ clear
#[H#[2J#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ nano philoshw.cpp
#[?1l#>#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ ./psim3c philoshw.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 philoshw.##[KModified.txt
Psim3 project: Concurrent Philosophers - Hold & Wait
Simulation date: Tue Jul 9 20:25:40 2013
creating fork0
creating fork1
creating fork2
creating fork3
creating fork4
Concurrent Philosophers Hold & Wait created
Philosopher0 created with 15.45 9.5
Philosopher1 created with 25.45 19.5
Philosopher2 created with 65.45 35.5
Philosopher3 created with 20.45 5.5
Philosopher4 created with 7.45 12.5
Philosopher2 think interval = 71.9825
Philosopher1 think interval = 24.4297
Philosopher0 think interval = 16.9921
Philosopher3 think interval = 19.6302
Philosopher4 think interval = 8.19358
-------------------------------------------------------------
Mutex % usage: 0
-------------------------------------------------------------
-------------------------------------------------------------
fork4 % usage: 0.651499 avg num items used: 1
% of time spent in res usage: 0.651499
-------------------------------------------------------------
-------------------------------------------------------------
fork3 % usage: 0.462515 avg num items used: 1
% of time spent in res usage: 0.462515
-------------------------------------------------------------
-------------------------------------------------------------
fork2 % usage: 0.610154 avg num items used: 1
% of time spent in res usage: 0.610154
-------------------------------------------------------------
-------------------------------------------------------------
fork1 % usage: 0.620995 avg num items used: 1
% of time spent in res usage: 0.620995
-------------------------------------------------------------
-------------------------------------------------------------
fork0 % usage: 0.826116 avg num items used: 1
% of time spent in res usage: 0.826116
-------------------------------------------------------------
Number of eat cycles Philosopher00 = 8
Total waiting time to eat Philosopher00 = 45.2336
Number of eat cycles Philosopher11 = 4
Total waiting time to eat Philosopher11 = 62.1303
Number of eat cycles Philosopher22 = 2
Total waiting time to eat Philosopher22 = 9.45542
Number of eat cycles Philosopher33 = 7
Total waiting time to eat Philosopher33 = 76.105
Number of eat cycles Philosopher44 = 11
Total waiting time to eat Philosopher44 = 37.5629
Average time waiting to eat: 46.0974
--------------------------------------------------
End of simulation Concurrent Philosophers - Hold & Wait Tue Jul 9 20:25:40 2013
#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ clear
#[H#[2J#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ nano philoscw.cpp
#[?1l#>#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ ./psim3c philoscw.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 philoscwModified.txt
Psim3 project: Concurrent Philosophers Problem Circular Wait
Simulation date: Tue Jul 9 20:26:55 2013
Concurrent Philosophers Circular Wait created
Philosopher0 created at 0
Philosopher1 created at 0
Philosopher2 created at 0
Philosopher3 created at 0
Philosopher4 created at 0
Philosopher0 thinking interval = 4.18779
Philosopher1 thinking interval = 8.17766
Philosopher2 thinking interval = 5.37377
Philosopher3 thinking interval = 45.2182
Philosopher4 thinking interval = 17.5569
-------------------------------------------------------------
fork4 % usage: 0.801396 avg num items used: 1
% of time spent in res usage: 0.801396
% of time spent waiting: 0.371017
-------------------------------------------------------------
-------------------------------------------------------------
fork3 % usage: 0.923135 avg num items used: 1
% of time spent in res usage: 0.923135
% of time spent waiting: 0.534555
-------------------------------------------------------------
-------------------------------------------------------------
fork2 % usage: 0.870512 avg num items used: 1
% of time spent in res usage: 0.870512
% of time spent waiting: 0.469977
-------------------------------------------------------------
-------------------------------------------------------------
fork1 % usage: 0.644891 avg num items used: 1
% of time spent in res usage: 0.644891
% of time spent waiting: 0.139954
-------------------------------------------------------------
-------------------------------------------------------------
fork0 % usage: 0.909789 avg num items used: 1
% of time spent in res usage: 0.909789
% of time spent waiting: 0.752047
-------------------------------------------------------------
Number of eating cycles phil 0 = 3
Total waiting interval to eat phil 0 = 84.2897
Number of eating cycles phil 1 = 5
Total waiting interval to eat phil 1 = 138.958
Number of eating cycles phil 2 = 6
Total waiting interval to eat phil 2 = 93.8562
Number of eating cycles phil 3 = 4
Total waiting interval to eat phil 3 = 149.836
Number of eating cycles phil 4 = 3
Total waiting interval to eat phil 4 = 42.4751
Average interval waiting to eat: 101.883
--------------------------------------------------
End of simulation Concurrent Philosophers Problem Circular Wait Tue Jul 9 20:26:55 2013
#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ clear
#[H#[2J#]0;dlabudov@cs3:~/dlabudov#[dlabudov@cs3 dlabudov]$ exit
exit
Script done on Tue 09 Jul 2013 08:27:02 PM EDT
Comments
Post a Comment