Operating Systems Concepts
Operating Systems Concepts
CONCEPTS
Process(1) 1 4
Process(2) 4 6
Process(3) 5 8
Available 8
Case B
Process(1) requests one deck. State unsafe
because there are not enough resources to
guarantee completion of all processes - request
denied.
03/15/2024 COM 221 29
Advantages of the Banker's Algorithm
• Does not allow mutual-exclusion, hold-and-
wait, and no pre-emption conditions
• System guarantees that processes will be
allocated resources within finite time.
Multiple threads can exist within the same process and share
resources such as memory, while different processes do not
share these resources. In particular, the threads of a process
share the latter's instructions (its code) and its context (the
values that its variables reference at any given moment).
CPU utilization
Turnaround time
From the point of view of a particular process, the important
criteria is how long it takes to execute that process. The
interval from the time of submission to the time of
completion is the turnaround time/turnaround time is the
sum of the periods spent waiting to get into memory waiting
in the ready queue, excluding on the CPU and doing I/O.
Response time
In an interactive system turn-around time may not be the best
criteria, often a process can produce some out put fairly early,
and continue computing new results while previous results are
being output to the user. Thus, another measure is the time from
the submission of a request until the first response is produced.
This measure called response time is the amount of time it takes
to start responding, but not time that it takes to output that
response. The turn around time is generally limited by the speed
of the output device. It is desirable to maximize CPU utilization
and throughout and to minimize turn around time, waiting time
and response time.
03/15/2024 COM 221 99
Scheduling Algorithms
CPU scheduling deals with the problem of deciding
which of the processes in the ready queue is to be
allocated the CPU, there are many different CPU
scheduling algorithms. Let us describe some of them.
3. Priority Scheduling
A priority is associated with each process and the CPU
is allocated to the process with highest priority. Equal
priority processes are scheduled in FCFS order.
Creating a file
Two stages are necessary to create a file;
• Space in the file system must be found for the file.
• An entry for the new file must be made in the directory.
The directory entry codes the name of the file and
location in the file system.
03/15/2024 COM 221 105
Reading a file; to read from a file, we use a
system call that specifies the name of the file
and where (if necessary) the next block of the
file should be found. The system needs to
keep a read pointer to the location in the file
where the next read is to take place.
Truncating a file
When a user wants the attributes of a file to
remain the same, but wants to erase contents of
the file, rather than forcing the user to delete the
file and then create it, this function allows
attributes to remain unchanged (except for the file
length) but for the file to be reset to length zero.
03/15/2024 COM 221 107
A common technique for implementing file types is to
include the type as part of the file name.
The name is spilt into two parts;
• A name and extension
Usually separated by a character or period.
In this way the user of a file and O.S can tell from the
name alone what type of a file is. e.g. in Ms. Word.
Name consists up to 8 characters followed by a period and
terminated by an up-to- three/four character extensions.
The system uses the extension to indicate the type of the
file and the type of operations that can be done on the
file. Only a file with com, exe and bat extensions can be
executed.
03/15/2024 COM 221 108
Access Methods
File storage devices store information when it is used, this information
must be accessed and read into computer memory. There are several
ways that the information in the file can be accessed.
1. Sequential Access
This is the simplest information in the file is processed in order, one
record after the other. e.g. editors and computers usually access files
in this fashion.
The bulk of the operation on a file one reads and writes.
Limitations
1. Since all files are in the same directory they must
have unique names
2. As the files increase it becomes difficult to remember
the names of all the files.
03/15/2024 COM 221 113
2. Two Level Directory
The major disadvantage to a single level directory is the
configuration of file names between different users. The
standard solution is to create a separate directory for each
user.
In two-level directory structure, each user has her own user
file directory.
The identification of a directory is indexed by user name or
account number.
When a user logs in, the system's master file directory is
searched.
When a user refers to a particular file, only his own (UFD) user
file directory is searched.
These different users may have files with same name as long
as they are in different directories.
03/15/2024 COM 221 114
The user directories themselves must be
created and deleted as necessary
Domain structure
Each domain defines a set of objects and the type
of operations that may be invoked on each object.
The ability to execute an operation on collection of
access rights, each of which is an ordered path <
object name, rights etc>
03/15/2024 COM 221 125
Domains can share access rights.
Allocation Methods
The direct access nature of disks allows us flexibility
in the implementation of files.
Many files are stored on the same disk.
The main problem is how to allocate space to these
files so that disk space is effectively utilized.
03/15/2024 COM 221 131
The three major methods of allocating disks space
are;
1. Contiguous Allocations
The contiguous allocation method requires each
file to occupy a set of contiguous blocks on the
disk.
Contiguous allocation of a file is defined by the disk
address and length (in block units) of first block if
the file is n blocks long and starts at location b,
then it occupies blocks b, b+l, b+z……….. b+n-1.
2. Linked List
Another approach is to link together all the free disk blocks
keeping a pointer to the first free block. This first block contains
a pointer to the next free disk block and so on.
03/15/2024 COM 221 141
Free-space list head