Study-Guide-OS in 30 Pages
Study-Guide-OS in 30 Pages
Study Guide
UNIT-I
Basic of Operating System and Its Structures Introduction: Computer System Organization-
Architecture-Structure-Operations. Management: Process-Memory-Storage. Structures:
Services-System Interface- System Calls- System Program-Design-structure
An OS is a program that acts as an intermediary between a user of a computer and the computer
hardware
Goals: Execute user programs, make the comp. system easy to use, utilize hardware efficiently
Computer system: Hardware ↔ OS ↔ Applications ↔ Users (↔ = 'uses')
OS is:
◦ Resource allocator: decides between conflicting requests for efficient and fair resource use
◦ Control program: controls execution of programs to prevent errors and improper use of
computer
Kernel: the one program running at all times on the computer
Bootstrap program: loaded at power-up or reboot
◦ Stored in ROM or EPROM (known as firmware), Initializes all aspects of system, loads OS
kernel and starts execution
I/O and CPU can execute concurrently
Device controllers inform CPU that it is finished w/ operation by causing an interrupt
◦ Interrupt transfers control to the interrupt service routine generally, through the interrupt
vector, which contains the addresses of all the service routines
◦ Incoming interrupts are disabled while another interrupt is being processed
◦ Trap is a software generated interrupt caused by error or user request
◦ OS determines which type of interrupt has occurred by polling or the vectored interrupt
system
System call: request to the operating system to allow user to wait for I/O completion
Device-status table: contains entry for each I/O device indicating its type, address, and state
◦ OS indexes into the I/O device table to determine device status and to modify the table entry
to include interrupt
Storage structure:
◦ Main memory – random access, volatile
◦ Secondary storage – extension of main memory That provides large non-volatile storage
◦ Disk – divided into tracks which are subdivided into sectors. Disk controller determines
logical interaction between the device and the computer.
Caching – copying information into faster storage system
Multiprocessor Systems: Increased throughput, economy o f
scale, increased reliability
◦ Can be asymmetric or symmetric
◦ Clustered systems – Linked multiprocessor systems
Multiprogramming – Provides efficiency via job scheduling
◦ When OS has to wait (ex: for I/O), switches to another job
Timesharing – CPU switches jobs so frequently that each user
can interact with each job while it is running (interactive computing)
Dual-mode operation allows OS to protect itself and other system components – User mode and
kernel mode
◦ Some instructions are only executable in kernel mode, these are privileged
Single-threaded processes have one program counter, multi-threaded processes have one PC per
thread
Protection – mechanism for controlling access of processes or users to resources defined by the
OS
Security – defense of a system against attacks
User IDs (UID), one per user, and Group IDs, determine which users and groups of users have
which privileges
UNIT -II
Ch.3 – Processes
Process contains a program counter, stack, and data section.
◦ Text section: program code itself
◦ Stack: temporary data (function parameters, return
addresses, local variables)
◦ Data section: global variables
◦ Heap: contains memory dynamically allocated during
run-time
Process Control Block (PCB): contains information
associated with each process: process state, PC, CPU
registers, scheduling information, accounting information, I/O status information
Types of processes:
◦ I/O Bound: spends more time doing I/O than
computations, many short CPU bursts
◦ CPU Bound: spends more time doing computations,
few very long CPU bursts
When CPU switches to another process, the system must
save the state of the old process (to PCB) and load the
saved state (from PCB) for the new process via a context
switch
◦ Time of a context switch is dependent on hardware
Parent processes create children processes (form a tree)
◦ PID allows for process management
◦ Parents and children can share all/some/none
resources
◦ Parents can execute concurrently with children or wait until children terminate
◦ fork() system call creates new process
▪ exec() system call used after a fork to replace the processes' memory space with a new
program
Cooperating processes need interprocess communication (IPC): shared memory or message
passing
Message passing may be blocking or non-blocking
◦ Blocking is considered synchronous
▪ Blocking send has the sender block until the message is received
▪ Blocking receive has the receiver block until a message is available
◦ Non-blocking is considered asynchronous
▪ Non-blocking send has the sender send the message and continue
▪ Non-blocking receive has the receiver receive a valid message or null
Ch.4 – Threads
Threads are fundamental unit of CPU utilization that forms the basis of multi-threaded computer
systems
Process creation is heavy-weight while thread creation is light-weight
◦ Can simplify code and increase efficiency
Kernels are generally multi-threaded
Multi-threading models include: Many-to-One, One-to-One, Many-to-Many
◦ Many-to-One: Many user-level threads mapped to single kernel thread
◦ One-to-One: Each user-level thread maps to kernel thread
◦ Many-to-Many: Many user-level threads mapped to many kernel threads
Thread library provides programmer with API for creating and managing threads
Issues include: thread cancellation, signal handling (synchronous/asynchronous), handling thread-
specific data, and scheduler activations.
◦ Cancellation:
▪ Asynchronous cancellation terminates the target thread immediately
▪ Deferred cancellation allows the target thread to periodically check if it should be
canceled
◦ Signal handler processes signals generated by a particular event, delivered to a process,
handled
◦ Scheduler activations provide upcalls – a communication mechanism from the kernel to the
thread library.
▪ Allows application to maintain the correct number of kernel threads
Ch.5 – Process Synchronization
Race Condition: several processes access and manipulate the same data concurrently, outcome
depends on which order each access takes place.
Each process has critical section of code, where it is manipulating data
◦ To solve critical section problem each process must ask permission to enter critical section
in entry section, follow critical section with exit section and then execute the remainder
section
◦ Especially difficult to solve this problem in preemptive kernels
Peterson's Solution: solution for two processes
◦ Two processes share two variables: int turn and Boolean flag[2]
◦ turn: whose turn it is to enter the critical section
◦ flag: indication of whether or not a process is ready to enter critical section
▪ flag[i] = true indicates that process Pi is ready
◦ Algorithm for process Pi:
do {
flag[i] = TRUE;
turn = j;
while (flag[j] && turn == j)
critical section
flag[i] = FALSE;
remainder section
} while (TRUE);
Modern machines provide atomic hardware instructions: Atomic = non-interruptable
Solution using Locks:
do {
acquire lock
critical section
release lock
remainder section
} while (TRUE);
Solution using Test-And-Set: Shared boolean variable lock, initialized to FALSE
do {
boolean TestAndSet (boolean *target){ while ( TestAndSet (&lock ))
boolean rv = *target; ; // do
*target = TRUE;" nothing
return rv: // critical section
} lock = FALSE;
// remainder section
} while (TRUE);
Solution using Swap: Shared bool variable lock initialized to FALSE; Each process has local bool
variable key
void Swap (boolean *a, boolean *b){ do {
boolean temp = *a; key = TRUE;
*a = *b; while ( key == TRUE)
*b = temp: Swap (&lock,
} &key );
// critical section
lock = FALSE;
// remainder section
} while (TRUE);
UNIT-III
Ch.7 – Deadlocks
Deadlock Characteristics: deadlock can occur if these conditions hold simultaneously
◦ Mutual Exclusion: only one process at a time can use a resource
◦ Hold and Wait: process holding one resource is waiting to acquire resource held by another
process
◦ No Preemption: a resource can be released only be the process holding it after the process
completed its task
◦ Circular Wait: set of waiting processes such that Pn-1 is waiting for resource from Pn, and Pn
is waiting for P0
▪ “Dining Philosophers” in deadlock
UNIT -IV
Ch.15 – Security
System secure when resources used and accessed as intended under
all circumstances
Attacks can be accidental or malicious
◦ Easier to protect against accidental than malicious misuse
Security violation categories:
◦ Breach of confidentiality – unauthorized reading of data
◦ Breach of integrity – unauthorized modification of data
◦ Breach of availability – unauthorized destruction of data
◦ Theft of service – unauthorized use of resources
◦ Denial of service – prevention of legitimate use
Methods of violation: Man-in-the-middle attack - Asymmetric
Cryptography
◦ Masquerading – pretending to be an authorized user
◦ Man-in-the-middle – intruder sits in data flow, masquerading as sender to receiver and vice
versa
◦ Session hijacking – intercept and already established session to bypass authentication
Effective security must occur at four levels: physical, human, operating system, network
Program threats: trojan horse (spyware, pop-up, etc.), trap door, logic bomb, stack and buffer
overflow
Viruses: code fragment embedded in legitimate program; self-replicating
◦ Specific to CPU architecture, OS, applications
◦ Virus dropper: inserts virus onto the system
Windows is the target for most attacks – most common, everyone is administrator
Worms: use spawn mechanism – standalone program
Port scanning: automated attempt to connect to a range of ports on one or a range of IP
addresses
◦ Frequently launched from zombie systems to decrease traceability
Denial of service: overload targeted computer preventing it from doing useful work
Cryptography: means to constrain potential senders and/or receivers – based on keys
◦ Allows for confirmation of source, receipt by specified destination, trust relationship
Encryption: [K of keys], [M of messages], [C of ciphertexts], function E:K to encrypt, function
D:K to decrypt
◦ Can have symmetric and asymmetric (distributes public encryption key, holds private
decipher key) encryption
▪ Asymmetric is much more compute intensive – not used for bulk data transaction
▪ Keys can be stored on a key ring
Authentication: constraining a set of potential senders of a message
◦ Helps to prove that the message is unmodified
◦ Hash functions are basis of authentication
▪ Creates small, fixed-size block of data (message digest, hash value)
Symmetric encryption used in message-authentication code (MAC)
Authenticators produced from authentication algorithm are digital signatures
Authentication requires fewer computations than encryption methods
Digital Certificates: proof of who or what owns a public key
Defense in depth: most common security theory – multiple layers of security
Can attempt to detect intrusion:
◦ Signature-based: detect “bad patterns”
◦ Anomaly detection: spots differences from normal behavior
▪ Both can report false positives or false negatives
Auditing, accounting, and logging specific system or network activity