/Resource-Allocation-Sim

Simulates oss resource allocation and deadlock avoidance. Randomly forks off children, reads resource request from a message queue, and calculates if system is in a safe state. Creates a clock structure in shared memory to track time. All events performed are recorded in a log file called log.txt by default or in a file designated by the -l option. To set the timer to termante the program, it uses a -t option.

Primary LanguageC

{\rtf1\ansi\ansicpg1252\cocoartf1671\cocoasubrtf100
{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
{\colortbl;\red255\green255\blue255;}
{\*\expandedcolortbl;;}
\margl1440\margr1440\vieww10800\viewh8400\viewkind0
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0

\f0\fs24 \cf0 Briton Powe\
OS - Assignment 5\
README\
\
This program simulates resource management with deadlock avoidance. Deadlock avoidance is\
achieved by implementing the banker\'92s algorithm. All actions by oss is logged in logfile.txt\
\
To run the program enter:\
\
./oss\
\
To run it with verbose (Allocation Table printed in logfile):\
\
./oss -v\
\
The default name for the log file is \'93logfile.txt\'94 and default run time is 2 real seconds.\
The name of the log file can be changed with the -l option and the default run time can \
be changed with -t option.\
\
When user processes make a choice, it is done so with a random number (1-100) inclusive.\
- 60% chance for requesting a resource for allocation.\
- 30% chance for releasing a resource\
- 10% chance for terminating\
\
When a user process has its request denied by oss, it becomes blocked. A user process \
does not change its choice until it is granted. This increases the chance that a lot resource\
requests to be blocked in the later half of the program.\
\
When verbose is turn on, the lines printed by the table are not counted. This will make the\
log file longer than 10,000 lines. \
\
Oss statistics are printed at the end of the log file.\
\
For the banker\'92s algorithm, the code was refactored from the following link:\
https://www.thecrazyprogrammer.com/2016/07/bankers-algorithm-in-c.html\
 }