Os - Unit V 1
Os - Unit V 1
Operating Systems
Unit – V
Secondary-Storage Structure: Overview of disk structure, and
attachment, Disk scheduling, RAID structure, Stable storage
implementation.
System Protection: Goals of protection, Principles and domain of
protection, Access matrix, Access control, Revocation of access
rights.
System Security: Introduction, Program threats, System and network
threats.
Case Studies: Linux, Microsoft Windows.
S sushma,IT Department
ADITYA ENGINEERING COLLEGE(A)
Size increases
cost decreases
speed decreases
S sushma,IT Department
ADITYA ENGINEERING COLLEGE(A)
Magneti c Disks
• A read–write head “flies” just above each surface of every
platter. The heads are attached to a disk arm that moves all the
heads as a unit. The surface of a platter is logically divided into
circular tracks, which are subdivided into
sectors. The set of tracks that are at one arm position makes
up a cylinder.
• There may be thousands of concentric cylinders in a disk drive,
and each track may contain hundreds of sectors. The storage
capacity of common disk drives is measured in gigabytes.
• When the disk is in use, a drive motor spins it at high speed.
Most drives rotate 60 to 250 times per second, specified in terms
of rotations per minute (RPM).
S sushma,IT Department
ADITYA ENGINEERING COLLEGE(A)
Magneti c Disks
• The transfer rate is the rate at which data flow between the
drive and the computer.
• The positioning time, or random-access time, consists of
• two parts: the time necessary to move the disk arm to the desired
cylinder, called the seek time, and the time necessary for the
desired sector to rotate to the disk head, called the rotational
latency.
S sushma,IT Department
ADITYA ENGINEERING COLLEGE(A)
Solid-State Disks
• SSD is nonvolatile memory that is used like a hard drive.
• SSDs have the same characteristics as traditional hard disks but can be more reliable because they have no moving parts and
faster because they have no seek time or latency.
• They consume less power.
• They are more expensive per megabyte than traditional hard disks, have less capacity than the larger hard disks, and may
have shorter life spans than hard disks.
S sushma,IT Department
ADITYA ENGINEERING COLLEGE(A)
Magneti c Tapes
• Magnetic tape was used as an early secondary-storage
medium.
• Although it is relatively permanent and can hold large
quantities of data, its access time is slow compared with
that of main memory and magnetic disk.
• Random Access to magnetic tape is about a thousand
times slower than random access to magnetic disk, so
tapes are not very useful for secondary storage.
• Tape capacities vary greatly, depending on the particular
kind of tape drive, with current capacities exceeding
several terabytes.
• Tapes are used mainly for backup, for storage of
infrequently used information.
• A tape is kept in a spool and is wound or rewound past a
S sushma,IT Department
ADITYA ENGINEERING COLLEGE(A)
Operating Systems
Disk Scheduling
S sushma,IT Department
ADITYA ENGINEERING COLLEGE(A)
Price per Megabyte of
Magnetic Hard Disk, From 1981 to 2004
S sushma,IT Department
ADITYA ENGINEERING COLLEGE(A)
S sushma,IT Department
ADITYA ENGINEERING COLLEGE(A)
Disk Scheduling
• The operating system is responsible for using hardware
efficiently — for the disk drives, this means having a
fast access time and disk bandwidth.
• Access time has two major components:
• Seek time is the time for the disk are to move the heads to
the cylinder containing the desired sector.
• Rotational latency is the additional time waiting for the disk
to rotate the desired sector to the disk head.
• Minimize seek time seek distance.
• Disk bandwidth is the total number of bytes
transferred, divided by the total time between the first
request for service Sand
sushma,ITthe completion of last transfer.
Department
ADITYA ENGINEERING COLLEGE(A)
S sushma,IT Department
ADITYA ENGINEERING COLLEGE(A)
Disk Scheduling
• There are many sources of disk I/O request:
• OS
• System processes
• Users processes
• I/O request includes input/output mode, disk address,
memory address, number of sectors to transfer.
• OS maintains queue of requests, per disk or device.
• Idle disk can immediately work on I/O request, busy
disk means work must queue:
• Optimization algorithms only make sense when a queue
exists.
S sushma,IT Department
ADITYA ENGINEERING COLLEGE(A)
Disk Structure
• Disk drives are addressed as large
1-dimensional arrays of logical blocks, where the
logical block is the smallest unit of transfer.
• The 1-dimensional array of logical blocks is mapped
into the sectors of the disk sequentially:
• Sector 0 is the first sector of the first track on the outermost
cylinder.
• Mapping proceeds in order through that track, then the rest
of the tracks in that cylinder, and then through the rest of
the cylinders from outermost to innermost.
S sushma,IT Department
ADITYA ENGINEERING COLLEGE(A)
• FCFS
• SSTF
Elevator Algorithms
• SCAN
• CSCAN
• LOOK
• CLOOK
S sushma,IT Department
ADITYA ENGINEERING COLLEGE(A)
• Note that drive controllers have small buffers and can manage a
queue of I/O requests (of varying “depth”).
• Several algorithms exist to schedule the servicing of disk I/O requests.
• The analysis is true for one or many platters.
• We illustrate them with a I/O request queue (cylinders are between
0-199):
S sushma,IT Department
ADITYA ENGINEERING COLLEGE(A)
S sushma,IT Department
ADITYA ENGINEERING COLLEGE(A)
S sushma,IT Department
ADITYA ENGINEERING COLLEGE(A)
Elevator Algorithms
• Algorithms based on the common elevator principle.
• Four combinations of Elevator algorithms:
– Service in both directions or in only one direction.
– Go until last cylinder or until last I/O request.
Scan Example
*In the SCAN algorithm, the disk arm starts
at one end of the disk and moves toward the
other end, servicing requests as it reaches
each cylinder, until it gets to the other end of
the disk. At the other end, the direction of
head movement
is reversed, and servicing continues. The head
continuously scans back and forth across the
disk.
*The SCAN algorithm is sometimes called the
elevator algorithm since the disk
armbehaves just like an elevator in a
building, first servicing all the requests
going up and then reversing to service
requests the other way.
C-Scan Example
*The head moves from one end of the disk to
the other, servicing requests as it goes. When it
reaches the other end, however, it immediately
returns to the beginning of the disk, without
servicing any requests on the return trip.
*When the head reaches the other end, however,
it immediately returns to the beginning of the
disk without servicing any requests on the return
trip.
*The C-SCAN scheduling algorithm essentially
treats the cylinders as a circular list that wraps
around from the final cylinder to the first one.
*Provides a more uniform wait time than SCAN;
it treats all cylinders in the same manner.
S sushma,IT Department
ADITYA ENGINEERING COLLEGE(A)
Look
S sushma,IT Department
ADITYA ENGINEERING COLLEGE(A)
C-Look Example
S sushma,IT Department
ADITYA ENGINEERING COLLEGE(A)
Another Example
LOOK C-LOOK
S sushma,IT Department
ADITYA ENGINEERING COLLEGE(A)
LOOK
S sushma,IT Department
C-LOOK
ADITYA ENGINEERING COLLEGE(A)
• Pickup
• A combination of FCFS and Look.
• Goes to next I/O request by FCFS but services all existing requests on the way
to it.
• Priority
• Goal is not to optimize disk use but to meet other objectives.
• Short batch jobs may have higher priority.
• Provide good interactive response time.
S sushma,IT Department
ADITYA ENGINEERING COLLEGE(A)
• FScan
• Use two queues.
• One queue is empty to receive new requests.
• N-step-Scan
• Segments the disk request queue into subqueues of
length N.
• Subqueues are processed one at a time, using Scan.
• New requests added to other queue when a certain queue
is processed.
S sushma,IT Department
ADITYA ENGINEERING COLLEGE(A)
S sushma,IT Department
ADITYA ENGINEERING COLLEGE(A)
Disk Structure
• Magnetic tape was used as an early secondary-storage medium.
• Although it is relatively permanent and can hold large quantities of data, its access time
is slow compared with that of main memory and magnetic disk
S sushma,IT Department
ADITYA ENGINEERING COLLEGE(A)
RAID Structure
The general idea behind RAID is to employ a group of hard drives together with some form of
duplication, either to increase reliability or to speed up operations, ( or sometimes both. )
RAID originally stood for Redundant Array of Inexpensive Disks, and was designed to use a bunch
of cheap small disks in place of one or two larger more expensive ones. Today RAID systems
employ large possibly expensive disks as their components, switching the definition to
Independent disks.
Striping: means spreading data out across multiple disks that can be accessed simultaneously.
S sushma,IT Department
ADITYA ENGINEERING COLLEGE(A)
RAID Levels
Raid Level 0 - This level includes striping only, with no mirroring.
Raid Level 2 - This level stores error-correcting codes on additional disks, allowing for any damaged data to be
reconstructed by subtraction from the remaining undamaged data. Note that this scheme requires only three extra
disks to protect 4 disks worth of data, as opposed to full mirroring. ( The number of disks required is a function of
the error-correcting algorithms, and the means by which the particular bad bit(s) is(are) identified.)
Raid Level 3 - This level is similar to level 2, except that it takes advantage of the fact that each disk is still doing its
own error-detection, so that when an error occurs, there is no question about which disk in the array has the bad
data. As a result a single parity bit is all that is needed to recover the lost data from an array of disks. Level 3 also
includes striping, which improves performance. The downside with the parity approach is that every disk must take
part in every disk access, and the parity bits must be constantly calculated and checked, reducing performance.
Hardware-level parity calculations and NVRAM cache can help with both of those issues. In practice level 3 is
greatly preferred over level 2.
S sushma,IT Department
ADITYA ENGINEERING COLLEGE(A)
RAID Levels
Raid Level 4 - This level is similar to level 3, employing block-level striping instead of bit- level striping. The benefits
are that multiple blocks can be read independently, and changes to a block only require writing two blocks ( data
and parity ) rather than involving all disks. Note that new disks can be added seamlessly to the system provided they
are initialized to all zeros, as this does not affect the parity results.
Raid Level 5 - This level is similar to level 4, except the parity blocks are distributed over all disks, thereby more
evenly balancing the load on the system. For any given block on the disk(s), one of the disks will hold the parity
information for that block and the other N-1 disks will hold the data. Note that the same disk cannot hold both data
and parity for the same block, as both would be lost in the event of a disk crash.
Raid Level 6 - This level extends raid level 5 by storing multiple bits of error-recovery codes, ( such as the
Reed-Solomon codes ), for each bit position of data, rather than a single parity bit. In the example shown below 2
bits of ECC are stored for every 4 bits of data, allowing data recovery in the face of up to two simultaneous disk
failures. Note that this still involves only 50% increase in storage needs, as opposed to 100% for simple mirroring
which could only tolerate a single disk failure.
S sushma,IT Department
ADITYA ENGINEERING COLLEGE(A)
RAID Levels
S sushma,IT Department
ADITYA ENGINEERING COLLEGE(A)
Stable-Storage Implementation
The concept of stable storage involves a storage medium in which data is never lost, even in the face of
equipment failure in the middle of a write operation.
To implement this requires two ( or more ) copies of the data, with separate failure modes.
2. The data is partially written, but not completely. The last block written may be garbled.
S sushma,IT Department
ADITYA ENGINEERING COLLEGE(A)
Stable-Storage Implementation
• Whenever an equipment failure occurs during a write, the system must detect it, and return the system
back to a consistent state. To do this requires two physical blocks for every logical block, and the following
procedure:
2. After step 1 had completed, then write the data to the second physical block.
3. Declare the operation complete only after both physical writes have completed successfully.
S sushma,IT Department
ADITYA ENGINEERING COLLEGE(A)
Stable-Storage Implementation
• During recovery the pair of blocks is examined.
If both blocks are identical and there is no sign of damage, then no further action is necessary.
If one block contains a detectable error but the other does not, then the damaged block is replaced with the
good copy. ( This will either undo the operation or complete the operation, depending on which block is
damaged and which is undamaged. )
If neither block shows damage but the data in the blocks differ, then replace the data in the first block with the
data in the second block. ( Undo the operation. )
• Because the sequence of operations described above is slow, stable storage usually includes NVRAM as a
cache, and declares a write operation complete once it has been written to the NVRAM.
S sushma,IT Department
ADITYA ENGINEERING COLLEGE(A)
Operating System Concepts – 8th Edition, Silberschatz, Galvin and Gagne ©2009
Operating System Concepts – 8th Edition 14.3 Silberschatz, Galvin and Gagne ©2009
Goals of Protection
Operating system consists of a collection of objects, hardware or software
Each object has a unique name and can be accessed through a well- defined set of operations.
Protection problem - ensure that each object is accessed correctly and only by those processes that are allowed to do so.
14.4
ADITYA ENGINEERING COLLEGE(A)
Principles of Protection
Guiding principle – principle of least privilege
Programs, users and systems should be given just enough privileges to perform their tasks
Operating System Concepts – 8th Edition 14.5 Silberschatz, Galvin and Gagne ©2009
Domain Structure
Access-right = <object-name, rights-set>
where rights-set is a subset of all valid operations that can be performed on the object.
14.6
ADITYA ENGINEERING COLLEGE(A)
Domain Implementation (UNIX)
System consists of 2 domains:
User
Supervisor
UNIX
Domain = user-id
Domain switch accomplished via file system.
Each file has associated with it a domain bit (setuid bit).
When file is executed and setuid = on, then user-id is set to owner of the file being executed. When execution completes user-id
is reset.
Operating System Concepts – 8th Edition 14.7 Silberschatz, Galvin and Gagne ©2009
14.8
ADITYA ENGINEERING COLLEGE(A)
Access Matrix
View protection as a matrix (access matrix)
Access(i, j) is the set of operations that a process executing in Domaini can invoke on Objectj
Operating System Concepts – 8th Edition 14.9 Silberschatz, Galvin and Gagne ©2009
Access Matrix
14.10
ADITYA ENGINEERING COLLEGE(A)
Use of Access Matrix
If a process in Domain Di tries to do “op” on object Oj, then “op” must be in the access matrix.
14.12
ADITYA ENGINEERING COLLEGE(A)
Implementation of Access Matrix
Each column = Access-control list for one object Defines who can perform what
operation.
Domain 1 = Read, Write Domain 2 = Read Domain 3 = Read
⁝
Each Row
Fore each= domain,
Capability Listoperations
what (like a key)
allowed on what objects.
Object 1 – Read
Object 4 – Read, Write, Execute Object 5 – Read, Write, Delete, Copy
Operating System Concepts – 8th Edition 14.13 Silberschatz, Galvin and Gagne ©2009
Figure B
14.14
ADITYA ENGINEERING COLLEGE(A)
Access Matrix with Copy Rights
Operating System Concepts – 8th Edition 14.15 Silberschatz, Galvin and Gagne ©2009
14.16
ADITYA ENGINEERING COLLEGE(A)
Modified Access Matrix of Figure B
Operating System Concepts – 8th Edition 14.17 Silberschatz, Galvin and Gagne ©2009
Access Control
Protection can be applied to non-file resources
Solaris 10 provides role-based access control to implement least privilege
Privilege is right to execute system call or use an option within a system call
Can be assigned to processes
Users assigned roles granting access to privileges and programs
14.18
ADITYA ENGINEERING COLLEGE(A)
Role-based Access Control in Solaris 10
Operating System Concepts – 8th Edition 14.19 Silberschatz, Galvin and Gagne ©2009
Capability List – Scheme required to locate capability in the system before capability can be revoked.
Reacquisition
Back-pointers
Indirection
Keys
14.20
Chapter 15: Security
Operating System Concepts – 8th Edition Silberschatz, Galvin and Gagne ©2009
ADITYA ENGINEERING COLLEGE(A)
Objectives
• To discuss security threats and attacks
• Impossible to have absolute security, but make cost to perpetrator sufficiently high
to deter most intruders
• Security must occur at four levels to be effective:
• Physical
• Data centers, servers, connected terminals
• Human
• Avoid social engineering, phishing, dumpster diving
• Operating System
• Protection mechanisms, debugging
• Network
• Intercepted communications, interruption, DOS
• Security is as weak as the weakest link in the chain
• But can too much security be a problem?
ADITYA ENGINEERING COLLEGE(A)
Program Threats
• Many variations, many names
• Trojan Horse
• Code segment that misuses its environment
• Exploits mechanisms for allowing programs written by users to be executed
by other users
• Spyware, pop-up browser windows, covert channels
• Up to 80% of spam delivered by spyware-infected systems
• Trap Door
• Specific user identifier or password that circumvents normal security
procedures
• Could be included in a compiler
• How to detect them?
ADITYA ENGINEERING COLLEGE(A)
#include <stdio.h>
#define BUFFER SIZE 256
int main(int argc, char *argv[])
{
char buffer[BUFFER SIZE];
if (argc < 2)
return -1;
else {
strcpy(buffer,argv[1]);
return 0;
}
}
ADITYA ENGINEERING COLLEGE(A)
Layout of Typical Stack Frame
ADITYA ENGINEERING COLLEGE(A)
Modified Shell Code
#include <stdio.h>
int main(int argc, char *argv[])
{
execvp(‘‘\bin\sh’’,‘‘\bin \sh’’, NULL);
return 0;
}
ADITYA ENGINEERING COLLEGE(A)
Hypothetical Stack Frame
Sobig.F Worm
• More modern example
• Disguised as a photo uploaded to adult newsgroup via account created with stolen credit card
• Had own SMTP engine to mail itself as attachment to everyone in infect system’s address book
• Disguised with innocuous subject lines, looking like it came from someone known
• Attachment was executable program that created WINPPR23.EXE in default Windows system directory
Plus the Windows Registry
[HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]
"TrayX" = %windir%\winppr32.exe /sinc
[HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]
"TrayX" = %windir%\winppr32.exe /sinc