Unit 4 - Operating System - WWW - Rgpvnotes.in PDF
Unit 4 - Operating System - WWW - Rgpvnotes.in PDF
Tech
Subject Name: Operating System
Subject Code: IT-501
Semester: 5th
Downloaded from www.rgpvnotes.in
implementation technology. The cache has a limited volume that also results from the properties of the
applied technology. If information fetched to the cache memory is used again, the access time to it will be
much shorter than in the case if this information were stored in the main memory and the program will
execute faster.
Time efficiency of using cache memories results from the locality of access to data that is observed during
program execution.
Time locality: Time locality consists in a tendency to use many times the same instructions and data in
programs during neighboring time intervals.
Space locality: Space locality is a tendency to store instructions and data used in a program in short distances
of time under neighboring addresses in the main memory.
Due to these localities, the information loaded to the cache memory is used several times and the
execution time of programs is much reduced.
Cache can be implemented as a multi-level memory. Contemporary computers usually have two levels
of caches. In older computer models, a cache memory was installed outside a processor (in separate
integrated circuits than the processor itself).
The access to it was organized over the processor external system bus. In today's computers, the first
level of the cache memory is installed in the same integrated circuit as the processor.
It significantly speeds up processor's co-operation with the cache. Some microprocessors have the
second level of cache memory placed also in the processor's integrated circuit.
The volume of the first level cache memory is from several thousands to several tens of thousands of
bytes. The second level cache memory has volume of several hundred thousand bytes.
A cache memory is maintained by a special processor subsystem called cache controller.
Write through, the new cache contents is written down to the main memory immediately after the
write to the cache memory,
Write back, the new cache contents are not written down to the main memory immediately after the
change, but only when the given block of data is replaced by a new block fetched from the main
memory or an upper level cache. After a data write to the cache, only state bits are changed in the
modified block, indicating that the block has been modified (a dirty block).
Demand Paging
A demand paging system is quite similar to a paging system with swapping where processes reside in
secondary memory and pages are loaded only on demand, not in advance. When a context switch occurs, the
operating system does not copy any of the old program’s pages out to the disk or any of the new program’s
pages into the main memory Instead, it just begins executing the new program after loading the first page and
fetches that program’s pages as they are referenced.
● If we have a reference to a page p, then any immediately following references to page p will never
cause a page fault. Page p will be in memory after the first reference; the immediately following
references will not fault.
● For example, consider the following sequence of addresses − 123,215,600,1234,76,96
● If page size is 100, then the reference string is 1,2,6,12,0,0
First in First Out (FIFO) algorithm
● Oldest page in main memory is the one which will be selected for replacement.
● Easy to implement, keep a list, replace pages from the tail and add new pages at the head.
Allocation of Frames
● Maintain 3 free frames at all times
● Consider a machine where all memory-reference instructions have only 1 memory address → need 2
frames of memory
● Now consider indirect modes of addressing
● Potentially every page in virtual memory could be touched, and the entire virtual memory must
be in physical memory
● Place a limit the levels of indirection
● The minimum number of frames per process is defined by the computer architecture
● The maximum number of frames is defined by the amount of available physical memory
Allocation Algorithms
● m frames, n processes
● Equal allocation: give each process m/n frames
● Alternative is to recognize that various processes will need different amounts of memory
● Consider
● 1k frame size
● 62 free frames
● student process requiring: 10k
● interactive database requiring: 127k
It makes no sense to give each process 31 frames the student process needs no more than 10 so the additional
21 frames are wasted
● proportional allocation:
● m frames available
● Size of virtual memory for process pi is si
● S = Sigma si
● ai = (si/S) * m
Student process gets 4 frames = (10/137)*62
Database gets 57 frames = (127/137)*62
● Global: one process can select a replacement frame from the set of all frames (i.e., one process can
take a frame from another or itself) (e.g., high priority processes can take the frames of low priority
processes)
● Local: each process can only select from its own set of allocated frames
● local page replacement is more predictable; depends on no external factors
● A process which uses global page replacement cannot predict the page fault rate; may execute in 0.5
seconds once and 10.3 on another run
● Overall, global replacement results in greater system throughput
Thrashing
● simple thrashing: 1 process of 2 pages only allocated 1 frame
● High page activity is called thrashing
● A process is thrashing if it spends more time paging than executing
Scenario:
● The process scheduler sees that CPU utilization is low.
● So we increase the degree of multiprogramming by introducing a new process into the system.
● One process now needs more frames.
● It starts faulting and takes away frames from other processes. (i.e., global-page replacement).
● These processes need those pages and thus they start to fault, taking frames from other processes.
● These faulting processes must use the paging device to swap pages in and out.
● As they queue up on the paging device, the ready-queue empties.
● However, as processes wait on the paging device, CPU utilization decreases.
● The process scheduler sees the decreasing CPU utilization and increases the degree of
multiprogramming, ad infinitum.
● The result is thrashing, page-fault rates increase tremendously, effective memory access time
increases, no work is getting done, because all the processes are spending their time paging.
● We can limit the effects of thrashing by using a local replacement algorithm (or priority replacement
algorithm)
● But this only partially solves the problem
If one process starts thrashing, it cannot steal frames of another process and cause the later to
thrash.
● However, the thrashing processes will be in the paging device queue which will increase the
time for a page fault to be serviced and, therefore, the effective access time will increase even
for those processes not thrashing.
● To really prevent thrashing, we must provide processes with as many frames as they need.
● But how do we know how many frames a process "needs"?
● Look at how many frames a process actually "uses".
Demand Demand
Consideration
Paging Segmentation
Programmer aware No Yes
How many addr spaces 1 Many
VA size > PA size Yes Yes
Protect individual
No Yes
procedures separately
Accommodate elements
No Yes
with changing sizes
Ease user sharing No Yes
let the VA size Sharing, Protection,
Why invented
exceed the PA size independent addr spaces
Internal fragmentation Yes No, in principle
External fragmentation No Yes
Placement question No Yes
Role of OS in 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 an unauthorized
user runs a computer program, then he/she may cause severe damage to computer or data stored in it. So a
computer system protected against unauthorized access, malicious access to system memory, viruses, worms
etc. We are going to discuss following topics.
● 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 used again. One-time password implemented in various ways
● Random numbers − Users are provided cards having numbers printed along with corresponding
alphabets. System asks for numbers corresponding 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 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 known as Program Threats. One of the common examples 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 generally a small code embedded
in a program. As user accesses the program, the virus starts embedded in other files/ programs and
can make system unusable for user
System Threats
System threats refer to misuse of system services and network connections to put user in trouble. System
threats used to launch program threats on a complete network called as program attack. System threats
create 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.
1 Type A
Highest Level uses formal design specifications and verification techniques. Grants a high degree
of assurance of process security
2 Type B
Provides mandatory protection system have all the properties of a class C2 system. Attaches a
sensitivity label to each object
It is of three types.
B1 − Maintains the security label of each object in the system. Label is used for making
decisions to access control.
B2 − Extends the sensitivity labels to each system resource, such as storage objects,
supports covert channels and auditing of events.
B3 − Allows creating lists or user groups for access-control to grant access or revoke
access to a given named object.
3 Type C
Provides protection and user accountability using audit capabilities
It is of two types.
C1 − Incorporates controls so that users can protect their private information and keep
other users from accidentally reading / deleting their data. UNIX versions are mostly Cl
class.
C2 − Adds an individual-level access control to the capabilities of a Cl level system.
4 Type D
Lowest level Minimum- protection MS-DOS, Window 3.1 fall in this category
Virus in details:
A virus is a fragment of code embedded in an otherwise legitimate program, designed to replicate itself
(by infecting other programs), and (eventually) wreaking havoc.
Viruses are more likely to infect PCs than UNIX or other multi-user systems, because programs in the
latter systems have limited authority to modify other programs or to access critical system structures
(such as the boot block.)
Viruses are delivered to systems in a virus dropper, usually some form of a Trojan horse, and usually
via e-mail or unsafe downloads.
Figure 4.6 shows typical operation of a boot sector virus:
Security Techniques
Design Principles Saltzer and Schroeder (1975) identified a core set of principles to operating system security
design:
Least privilege: Every object (users and their processes) should work within a minimal set of privileges; access
rights should be obtained by explicit request, and the default level of access should be “none”.
Economy of mechanisms: Security mechanisms should be as small and simple as possible, aiding in their
verification. This implies that they should be integral to an operating system’s design, and not an afterthought.
Acceptability: Security mechanisms must at the same time be robust yet non-intrusive. An intrusive
mechanism is likely to be counter-productive and avoided by users, if possible.
Complete: Mechanisms must be pervasive and access control checked during all operations — including the
tasks of backup and maintenance.
Open design: An operating system’s security should not remain secret, nor be provided by stealth. Open
mechanisms are subject to scrutiny, review, and continued refinement.
Security breaches: The OS must protect itself from security breaches, such as runaway processes (denial of
service), memory-access violations, stack overflow violations, the launching of programs with excessive
privileges, and many others.
Stack and Buffer Overflow: This is a classic method of attack, which exploits bugs in system code that allows
buffers to overflow.
Consider what happens in the following code, for example, if argv[ 1 ] exceeds 256 characters:
The strcpy command will overflow the buffer, overwriting adjacent areas of memory.
(The problem could be avoided using strncpy, with a limit of 255 characters copied plus room for the
null byte.)
#include
#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;
}
}
System Protection:
Goals of Protection
Obviously to prevent malicious misuse of the system by users or programs.
To ensure that each shared resource is used only in accordance with system policies, which may be set
either by system designers or by system administrators.
To ensure that errant programs cause the minimal amount of damage possible.
Note that protection systems only provide the mechanisms for enforcing policies and ensuring reliable
systems. It is up to administrators and users to implement those mechanisms effectively.
Principles of Protection
The principle of least privilege dictates that programs, users, and systems be given just enough
privileges to perform their tasks.
This ensures that failures do the least amount of harm and allow the least of harm to be done.
For example, if a program needs special privileges to perform a task, it is better to make it a SGID
program with group ownership of "network" or "backup" or some other pseudo group, rather than
SUID with root ownership. This limits the amount of damage that can occur if something goes wrong.
Typically each user is given their own account, and has only enough privilege to modify their own files.
The root account should not be used for normal day to day activities - The System Administrator should
also have an ordinary account, and reserve use of the root account for only those tasks which need the
root privileges
Domain of Protection
A computer can be viewed as a collection of processes and objects (both HW & SW).
The need to know principle states that a process should only have access to those objects it needs to
accomplish its task, and furthermore only in the modes for which it needs access and only during the
time frame when it needs access.
The modes available for a particular object may depend upon its type.
Domain Structure
A protection domain specifies the resources that a process may access.
Each domain defines a set of objects and the types of operations that may be invoked on each object.
An access right is the ability to execute an operation on an object.
A domain is defined as a set of < object, {access right set} > pairs, as shown below. Note that some
domains may be disjoint while others overlap.
Password Management
There are several forms of software used to help users or organizations better manage passwords:
Intended for use by a single user:
o Password manager software is used by individuals to organize and encrypt many personal
passwords using a single login. This often involves the use of an encryption keyas well.
Password managers are also referred to as password wallets.
Intended for use by a multiple users/groups of users: