0% found this document useful (0 votes)
10 views

Unit 5 Operating System

Uploaded by

rathodnikil07
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Unit 5 Operating System

Uploaded by

rathodnikil07
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Operating System

Unit 5: File System

File
A file is a named collection of related information that is recorded on secondary
storage such as magnetic disks, magnetic tapes and optical disks. In general, a file
is a sequence of bits, bytes, lines or records whose meaning is defined by the files
creator and user.
File Structure
A File Structure should be according to a required format that the operating
system can understand.
 A file has a certain defined structure according to its type.
 A text file is a sequence of characters organized into lines.
 A source file is a sequence of procedures and functions.
 An object file is a sequence of bytes organized into blocks that are
understandable by the machine.
 When operating system defines different file structures, it also contains the
code to support these file structure. Unix, MS-DOS support minimum
number of file structure.
File Type
File type refers to the ability of the operating system to distinguish different types
of file such as text files source files and binary files etc. Many operating systems
support many types of files. Operating system like MS-DOS and UNIX have the
following types of files −
Ordinary files

 These are the files that contain user information.


 These may have text, databases or executable program.
 The user can apply various operations on such files like add, modify, delete
or even remove the entire file.
Directory files

 These files contain list of file names and other information related to these
files.
Special files

 These files are also known as device files.


 These files represent physical device like disks, terminals, printers,
networks, tape drive etc.
These files are of two types −
 Character special files − data is handled character by character as in case
of terminals or printers.
 Block special files − data is handled in blocks as in the case of disks and
tapes.
File Access Mechanisms
File access mechanism refers to the manner in which the records of a file may be
accessed. There are several ways to access files −

 Sequential access
 Direct/Random access
 Indexed sequential access
Sequential access
A sequential access is that in which the records are accessed in some sequence,
i.e., the information in the file is processed in order, one record after the other.
This access method is the most primitive one. Example: Compilers usually access
files in this fashion.
Direct/Random access
 Random access file organization provides, accessing the records directly.
 Each record has its own address on the file with by the help of which it can
be directly accessed for reading or writing.
 The records need not be in any sequence within the file and they need not be
in adjacent locations on the storage medium.
Indexed sequential access

 This mechanism is built up on base of sequential access.


 An index is created for each file which contains pointers to various blocks.
 Index is searched sequentially and its pointer is used to access the file
directly.
Space Allocation
Files are allocated disk spaces by operating system. Operating systems deploy
following three main ways to allocate disk space to files.

 Contiguous Allocation
 Linked Allocation
 Indexed Allocation
Contiguous Allocation

 Each file occupies a contiguous address space on disk.


 Assigned disk address is in linear order.
 Easy to implement.
 External fragmentation is a major issue with this type of allocation
technique.
Linked Allocation

 Each file carries a list of links to disk blocks.


 Directory contains link / pointer to first block of a file.
 No external fragmentation
 Effectively used in sequential access file.
 Inefficient in case of direct access file.
Indexed Allocation

 Provides solutions to problems of contiguous and linked allocation.


 A index block is created having all pointers to files.
 Each file has its own index block which stores the addresses of disk space
occupied by the file.
 Directory contains the addresses of index blocks of files.
A deadlock happens in operating system when two or more processes need some
resource to complete their execution that is held by the other process.

In the above diagram, the process 1 has resource 1 and needs to acquire resource 2.
Similarly process 2 has resource 2 and needs to acquire resource 1. Process 1 and
process 2 are in deadlock as each of them needs the other’s resource to complete
their execution but neither of them is willing to relinquish their resources.
Coffman Conditions
A deadlock occurs if the four Coffman conditions hold true. But these conditions
are not mutually exclusive.
The Coffman conditions are given as follows −

 Mutual Exclusion
There should be a resource that can only be held by one process at a time. In
the diagram below, there is a single instance of Resource 1 and it is held by
Process 1 only.

Hold and Wait


A process can hold multiple resources and still request more resources from other
processes which are holding them. In the diagram given below, Process 2 holds
Resource 2 and Resource 3 and is requesting the Resource 1 which is held by
Process 1.

No Preemption
A resource cannot be preempted from a process by force. A process can only
release a resource voluntarily. In the diagram below, Process 2 cannot preempt
Resource 1 from Process 1. It will only be released when Process 1 relinquishes it
voluntarily after its execution is complete.
Circular Wait
A process is waiting for the resource held by the second process, which is waiting
for the resource held by the third process and so on, till the last process is waiting
for a resource held by the first process. This forms a circular chain. For example:
Process 1 is allocated Resource2 and it is requesting Resource 1. Similarly, Process
2 is allocated Resource 1 and it is requesting Resource 2. This forms a circular wait
loop.
Deadlock Detection
A deadlock can be detected by a resource scheduler as it keeps track of all the
resources that are allocated to different processes. After a deadlock is detected, it
can be resolved using the following methods −

 All the processes that are involved in the deadlock are terminated. This is
not a good approach as all the progress made by the processes is destroyed.
 Resources can be preempted from some processes and given to others till the
deadlock is resolved.
Deadlock Prevention
It is very important to prevent a deadlock before it can occur. So, the system
checks each transaction before it is executed to make sure it does not lead to
deadlock. If there is even a slight chance that a transaction may lead to deadlock in
the future, it is never allowed to execute.
Deadlock Avoidance
It is better to avoid a deadlock rather than take measures after the deadlock has
occurred. The wait for graph can be used for deadlock avoidance. This is however
only useful for smaller databases as it can get quite complex in larger databases.

Security
Security refers to providing a protection system to computer system resources such
as CPU, memory, disk, software programs and most importantly data/information
stored in the computer system. If a computer program is run by an unauthorized
user, then he/she may cause severe damage to computer or data stored in it. So a
computer system must be protected against unauthorized access, malicious access
to system memory, viruses, worms etc.

 Authentication
 One Time passwords
 Program Threats
 System Threats
 Computer Security Classifications
Authentication
Authentication refers to identifying each user of the system and associating the
executing programs with those users. It is the responsibility of the Operating
System to create a protection system which ensures that a user who is running a
particular program is authentic. Operating Systems generally
identifies/authenticates users using following three ways −
 Username / Password − User need to enter a registered username and
password with Operating system to login into the system.
 User card/key − User need to punch card in card slot, or enter key
generated by key generator in option provided by operating system to login
into the system.
 User attribute - fingerprint/ eye retina pattern/ signature − User need to
pass his/her attribute via designated input device used by operating system
to login into the system.
One Time passwords
One-time passwords provide additional security along with normal authentication.
In One-Time Password system, a unique password is required every time user
tries to login into the system. Once a one-time password is used, then it cannot be
used again. One-time password are implemented in various ways.
 Random numbers − Users are provided cards having numbers printed
along with corresponding alphabets. System asks for numbers
corresponding to few alphabets randomly chosen.
 Secret key − User are provided a hardware device which can create a secret
id mapped with user id. System asks for such secret id which is to be
generated every time prior to login.
 Network password − Some commercial applications send one-time
passwords to user on registered mobile/ email which is required to be
entered prior to login.
Program Threats
Operating system's processes and kernel do the designated task as instructed. If a
user program made these process do malicious tasks, then it is known as Program
Threats. One of the common example of program threat is a program installed in
a computer which can store and send user credentials via network to some hacker.
Following is the list of some well-known program threats.
 Trojan Horse − Such program traps user login credentials and stores them
to send to malicious user who can later on login to computer and can access
system resources.
 Trap Door − If a program which is designed to work as required, have a
security hole in its code and perform illegal action without knowledge of
user then it is called to have a trap door.
 Logic Bomb − Logic bomb is a situation when a program misbehaves only
when certain conditions met otherwise it works as a genuine program. It is
harder to detect.
 Virus − Virus as name suggest can replicate themselves on computer
system. They are highly dangerous and can modify/delete user files, crash
systems. A virus is generatlly a small code embedded in a program. As user
accesses the program, the virus starts getting embedded in other files/
programs and can make system unusable for user
System Threats
System threats refers to misuse of system services and network connections to put
user in trouble. System threats can be used to launch program threats on a
complete network called as program attack. System threats creates such an
environment that operating system resources/ user files are misused. Following is
the list of some well-known system threats.
 Worm − Worm is a process which can choked down a system performance
by using system resources to extreme levels. A Worm process generates its
multiple copies where each copy uses system resources, prevents all other
processes to get required resources. Worms processes can even shut down
an entire network.
 Port Scanning − Port scanning is a mechanism or means by which a hacker
can detects system vulnerabilities to make an attack on the system.
 Denial of Service − Denial of service attacks normally prevents user to
make legitimate use of the system. For example, a user may not be able to
use internet if denial of service attacks browser's content settings.

You might also like