0% found this document useful (0 votes)
7 views40 pages

Os All

An Operating System (OS) is essential software that manages hardware, software, memory, and processes, allowing users to control and communicate with a computer. It includes various managers such as Memory Manager, Processor Manager, and Device Manager, and can be categorized into types like batch, interactive, real-time, hybrid, and embedded systems. The document also discusses the evolution of operating systems and memory management techniques, including paging and various allocation schemes.

Uploaded by

matashaira042
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views40 pages

Os All

An Operating System (OS) is essential software that manages hardware, software, memory, and processes, allowing users to control and communicate with a computer. It includes various managers such as Memory Manager, Processor Manager, and Device Manager, and can be categorized into types like batch, interactive, real-time, hybrid, and embedded systems. The document also discusses the evolution of operating systems and memory management techniques, including paging and various allocation schemes.

Uploaded by

matashaira042
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Chapter 1

What is an Operating System?

• An Operating System is a group of programs that allow a user to control and communicate with a
computer.

• It manages the hardware, software, memory, and processes of the computer. • It is the most
important software that runs on a computer.

• Normally, a number of computer programs operate concurrently, requiring access to the computer's
processor (CPU), memory, and storage.

What is an Operating System?

• Computer System

- Hardware (physical machine and electronic)

- Software (programs)

• Operating System

- Part of computer system (software)

- Manages all hardware and software

- Controls every file, device, section of main memory and nanosecond of processing time.

- OS is the central controller in a computer.

Commonly used Operating Systems

• Microsoft Windows

• macOS

• Linux

• Android

• iOS

Operating System Managers

• 5 Essential Managers of OS

1. Memory Manager

2. Processor Manager
3. Device Manager

4. File Manager

5. Network Manager

Manager Tasks

• Monitor its resources continuously.

• Enforce the system policies that determines who gets what, when, and how.

• Allocate and Deallocate the resource when appropriate.

History of Machine Hardware 1 2 3 4 5

Mainframe Minicomputer Supercomputer Microcomputer Server

Mainframe

• A large machine in size with high internal memory capacity.

• The IBM 360 (1964) is a classic example of an early mainframe

IBM 360 model 30

• Required an air-conditioned room about 18 feet square. • The CPU was 5 feet high and 6 feet wide.

• Internal memory of 64k.

• $200,000 in 1964 dollars.

MINI Computer

• Developed to meet the needs of smaller institutions

• Compared to mainframe

- Smaller in size and memory capacity - Cheaper

• Example: Digital Equipment Corp’s (early 1970) Price: less than $18,000

• Today minicomputers are known as midrange computers

SUPER Computer
• Massive machine that handles massive computations • It was developed primarily for government
applications • For military operations and weather forecasting • Example: Cray supercomputer

- 6 to 1,000 processors

- Performs up to 2.4 trillion floating-point

operations per second (2.4 teraflops)

• Uses:

- Scientific research

- Customer support or product development

MICRO Computer

• Developed for single users in the late 1970s

• Example: microcomputers by Tandy Corporation and Apple Computer, Inc. - Very little memory
(compared by today’ standards)

- 64k maximum capacity

• Physical size was smaller that the mini

• Microcomputer’s distinguishing

characteristic

- Single-user status

Workstations

• Most powerful microcomputers

• Developed for commercial, educational, and government enterprises

• Networked together

• Support engineering and technical users

- Massive mathematical computations

- Computer – aided design (CAD)

- Applications

Servers
• Powerful computers that provide specialized services to other computers on client/server networks.

• Examples:

- Print servers

- Internet servers

- Mail servers

• Each performs critical network tasks

Chapter 2
Types of Operating System

• Operating Systems for large and small computers fall into five categories distinguished by response
time and how data is entered into the system: batch, interactive, real-time, hybrid, and embedded
systems.

Types of Operating System

• Batch Systems

- Batch systems date from earliest computers, when they relied on stacks of punched cards or reels of
magnetic tape for input. - Jobs were entered by assembling the cards into a deck and running the entire
deck of cards through a card reader as a group – a batch.

- The efficiency of a batch system is measured in throughput – the number of jobs completed in a given
amount of time

(500 jobs/hour).

• Interactive Systems

- Give a faster turnaround than batch systems but are slower than the real-time systems.

- They were introduced to satisfy the demands of users who needed fast turnaround when debugging
their programs.

- It required the development of time-sharing software.

- If provides immediate feedback to the user and response time can be measured in fractions of a
second.

• Real-time Systems
- Used in time-critical environments where reliability is key and data must be processed within a strict
time limit.

- The time limit need not be ultra-fast (though it often is), but system response time must meet the
deadline or risk significant

consequences.

- These systems also need to provide contingencies to fail gracefully – that it preserve as much of the
system’s capabilities and data is possible to facilitate recovery.

- Must be 100% responsive all of the time.

• Two Types of Real-time Systems

- Hard real-time system – missing a deadline can cause the whole system to fail.

- Soft real-time system - missing a deadline only causes slower or weaker performance, not a full failure.

• Hybrid Systems

- Combination of batch and interactive system.

- Users can access the system and get fast responses.

- Accepts and runs batch programs in the background when the interactive load is light.

- It takes advantage of the free time between high-demand usage of the system and low-demand times.

- Many large computer systems are hybrid.

• Embedded Systems

- Computers placed inside other products to add features and capabilities. - For example, you find
embedded computers in household appliances, automobiles, digital music players, elevators, and
pacemakers.

- Each one is designated to perform a set of specific programs, which are not interchangeable among
systems.

- This permits the designers to make the operating system more efficient and take advantage of the
computer’s limited resources, such as memory, to their maximum.

History of Operating System Development

History of Operating System

• 1940s: first generation


- Time when computers are based on vacuum tube technology. - No standard operating system
software.

- Typical program included every instruction needed by computer to perform the tasks requested.

- Poor machine utilization

- CPU processed data and performed calculations for fraction of available time.

- Computers are the size of classrooms

- Compilers and Assemblers

• 1950s: second generation

- Focused on cost effectiveness of the system.

- Developed to meet the needs of new markets – government and business researchers.

- Computers were expensive

- Two widely adopted improvements

- Computer operators were hired to facilitate machine operations. - Concept of job scheduling: group
together programs with similar requirements.

- Expensive time lags between CPU and I/O devices.

- Job scheduling introduced the need for control cards, which defined the exact nature of each program
and its requirements. - First use of a job control language.
- Speed of I/O increased

- Blocking

- Buffering

- Spooling

• 1960s: third generation

- Faster CPUs

- Speed still caused problems when they interacted with printers and other I/O devices that ran at
slower speeds.

- The solution was multiprogramming, which introduced the concept of loading many programs at one
time and sharing the attention of a single CPU.

- The most common mechanism for implementing

multiprogramming was the introduction of the concept of the interrupt.

- Active multiprogramming

- occurs when the operating system interrupts a job process.

- Passive multiprogramming

- the operating system didn’t control the interrupts but waited for each job and an execution sequence.

• 1970s
- Main memory physical capacity limitations

- Multiprogramming schemes used to increase CPU

- Virtual memory developed to solve physical limitation - Database management software

- Became a popular tool because it organized data in an integrated manner, minimized redundancy, and
simplified updating and access of data.

- Programs started using English-like words, modular structures, and standard operations

• 1980s

- Cost/performance ratio improvement of computer components. - Hardware was more flexible, with
logical functions built on easily replaceable circuit boards.

- Firmware, a word used to indicate that a program is permanently held in read-only memory (ROM).

- Multiprocessing (having more than one processor).

- More complex languages were designed to coordinate the activities of the multiple processors
servicing a single job.

• 1990s

- The overwhelming demand for Internet capability sparked the proliferation of networking capability.

- The World Wide Web by Tim Berners-Lee made the internet accessible by computer users worldwide.

- Introduced a proliferation of multimedia applications demanding additional power, flexibility, and


device compatibility for most operating systems.

• 2000s

- Primary design features support:

- Multimedia applications

- Internet and Web access

- Client/server computing

- Computer systems requirements

- Increased CPU speed

- High-speed network attachments

- Increased number and variety of storage devices - Virtualization


- Single server supports different operating systems

Object-Oriented Design

• An important area of research that resulted in substantial efficiencies was that of the system
architecture of operating systems.

• The way their components are programmed and organized, specifically the use of object-oriented
design and the reorganization of the operating system’s nucleus, the kernel.

• The kernel is the part of the operating system that resides in memory at all times, performs the most
essential operating system tasks, and is protected by hardware from user tampering.

Early OS vs Object-Oriented OS

Chapter 3
Memory Management

• Refers to how computers manage their main memory.

• Resources (instructions and data) that the CPUs can immediately access are kept in the main memory.

• However, controlling the main memory is a challenging task that requires many approaches over time.

• Access Memory

• Random Access Memory (RAM)

• Core Memory

• Primary Storage
Early Memory Allocation Schemes

1) Single-user contiguous scheme

2) Fixed partitions

3) Dynamic partitions

4) Relocatable dynamic partitions

Single-user Contiguous Scheme

• This scheme requires a minimal amount of work done by the operating system’s Memory Manager.

• Program was loaded in its entirety into memory and allocated as much contiguous space in memory
as needed.

• Jobs are processed sequentially in a single-user system. • Doesn’t support multiprogramming or


networking.

Fixed Partition

• Static partitions

• Main memory is partitioned – one partition per job

• Size of the memory per partition can be equal or unequal

• Permits multiprogramming

• Partition sizes remain static unless and until computer system is shut down, reconfigured, and
restarted.

• Requires:

- Protection of the job’s memory space

- Matching job size with partition size

Fixed Partition

Table 1: A simplified fixed-partition memory table with the free partition shaded
Fixed Partition

Figure 2: Main memory use during fixed partition allocation of Table 1

Dynamic Partition

• Memory is divided into variable-sized partitions based on the size of the process/jobs being executed.

• Jobs are given only as much memory as they request when they are loaded.

- Available memory is kept in contiguous blocks

• Job allocation method

- First come, first serve allocation method

- Memory waste: comparatively small within partitions

Figure 3: Main memory

use during dynamic

partition allocation

Best Fit and First Fit Allocation

• Free partitions are allocated on the following basis/strategies: - First Fit memory allocation:

- First partition fitting the requirements

- Leads to fast allocation of memory space


- Best Fit memory allocation:

- Smallest partition fitting the requirements

- Results in least wasted space

- Internal fragmentation reduced, but not eliminated - Space vs Speed

First Fit Memory Allocation

Job Memo
Num ry
ber Reque
sted

J1 10K

J2 20K

J3 30K

J4 10K

Table 2: Example of First Fit Memory Allocation Scheme

Job List Table

First Fit Memory Allocation

Figure 4: Example
of

First Fit Free Scheme


Best Fit Memory Allocation

Job Memory
Number Requeste
d

J1 10K

J2 20K

J3 30K

J4 10K

Table 2: Example of Best Fit Memory Allocation Scheme

Job List Table

Best Fit Memory Allocation

Figure 5: Example
of

Best Fit Free Scheme

• First Fit memory allocation:

- Advantage: Faster in making allocation

- Disadvantage: Leads to memory waste

• Best Fit memory allocation:


- Advantage: Makes the best use of memory space

- Disadvantage: Slower in making allocation

Deallocation

• Freeing an allocated memory space

• For fixed-partition system:

- Resets the status of the memory block to “free” • Dynamic Partition

- Case 1: Joining Two Free Blocks

- Case 2: Joining Three Free Blocks

- Case 3: Deallocating an Isolated Block

Relocatable Dynamic Partitions

• Memory Manager relocates programs to gather together all of the empty blocks and compact them to
make one block of memory, large enough to accommodate some or all of the jobs waiting to get in

• The compaction of memory, sometimes referred to as garbage collection or defragmentation, is


performed by the operating system to reclaim fragmented sections of the memory space.

Virtual Memory

• A storage method that gives the user the impression that their main memory is quite large.

• By considering a portion of secondary memory as the main memory, this is accomplished.

• By giving the user the impression that there is memory available to load the process, this approach
allows them to load larger size programs than the primary memory that is accessible.

• By doing this, the level of multiprogramming will be enhanced, which will increase CPU consumption.

Paging in OS
• Paging is storage mechanism.

• It is used to retrieve processes/jobs from secondary memory to primary memory.

• The processes in the memory are divided into small equal blocks called pages.

• It also divides the physical memory into the same size pieces called frames. • Each of the pages
contains the process which is retrieved into main memory and is stored in one frame of memory.

• Note: it is very important to have pages and frames which are of equal sizes which are very useful for
mapping and complete utilization of memory.

Demand Paging

• A condition occurred in the Virtual Memory.

• The pages of the processes are stored in the secondary memory and the page is brought to the main
memory when required.

• The pages are brought to the main memory when required by the Page Replacement Algorithms.

• The process of calling the pages to main memory from secondary memory upon demand/request.

Page Replacement Algorithms

• In an Operating System that uses paging for memory management, a page replacement algorithm is
needed to decide which page needs to be replaced when a new page comes in.

• Page Replacement Algorithms:

1. First In First Out (FIFO) Replacement Algorithm

2. Least Recently Used (LRU) Replacement Algorithm

➢ Page Fault

- occurs when a program tries to access a memory page that is not present in the memory.

➢ Page Hit

- occurs when a program tries to access a memory page that is already present in the memory.

1. First In First Out (FIFO) Algorithm

- this is the simplest page replacement algorithm.

- In FIFO page replacement algorithm, the policy is to remove the pages that have been in memory the
longest.
First In First Out (FIFO) Algorithm

Interrupts = Page Fault

Page Fault = 9

Page Hit = 2

Page Replacement Algorithms

2. Least Recently Used (LRU) Algorithm

- In this algorithm, page will be replaced which is least recently used. - Page replacement policy swaps
out the pages that show the least amount of recent activity, figuring that these pages are the least likely
to be used again in the immediate future.

Least Recently Used (LRU) Algorithm


Interrupts = Page

Fault

Chapter 4
Processor Management

• If you were assembling some IKEA furniture, and following the step-by-step guide of 20 steps.

• Imagine you did step 1, then step 2, then step 3, suddenly the doorbell rang, and you are interrupted.

• You would stop what you are doing and deal with whoever is at the door. • Then you would return to
the assembly, check what step you were on, and then continue on from there (step 4).

Processor Management

• A “Process” is the basic unit of execution in the operating system

• A “Process” is the name we give to a program when it is running in memory. - A Program is a compiled
set of instructions that are stored in an executable file.

- A Process is the instance of this executable file that the operating system runs, along with its
associated resources and current state of execution (e.g., memory allocation)

• The Processor Manager is made up of two sub-managers: 1. Job Scheduler (High level scheduler)

2. Process Scheduler (Low level Scheduler)

Job Scheduler

• We describe a collection of processes as a “job”.

• When the operating systems is presented with a queue of jobs or processes to run, the Job Scheduler
has the task of deciding which order to run the jobs in.
• The Job Scheduler wants to ensure that all components of the operating system are busy, and there is
no component that is idle.

• Let’s think about this program:

PROGRAM PrintValue:

BEGIN

Input A;

Input B;

C = A + B;

D = A – B;

Print “The sum of inputs is: “, C;

Print “The Difference of inputs is: “, D; END.


• Others do a lot of computation, but little I/O, e.g. math programs.

• We'll call jobs that are CPU-bound Batch Jobs, and we’ll call jobs that have a lot of I/O operations

Interactive Jobs.
• So, in this case the Job Scheduler wants to balance the jobs coming in, so that the components of the
operating system are all kept busy. • If we don’t change the order of job, the CPU will be very busy, but
the I/O component will be idle, and then vice versa.

• This is not an optimal use of resources, so we swap them around.

• Every process has a field that records their current status, called the Process Control Block (PCB).

• When the process is first passed to the Job Scheduler from the operating system, its status is always
set as HOLD. • When the Job Scheduler passes the process onto the Process Scheduler, its status is
always changed to READY.

Process Scheduler

• Assigns the CPU to execute processes of those jobs placed on ready queue by Job Scheduler.

• After a job has been placed on the READY queue by Job Scheduler, Process Scheduler takes over:

- Determines which jobs will get CPU, when, and for how long. - Decides when processing should be
interrupted.

- Determines queues job should be moved to during execution. - Recognizes when a job has concluded
and should be terminated.

Processor Management: Middle-Level Scheduler


• In a highly interactive environment there’s a third layer called middle-level scheduler.

• Removes active jobs from memory to reduce degree of multiprogramming and allows jobs to be
completed faster.

Job and Process Status

• When the jobs moves through the system and makes progress, it changes its states from HOLD to
FINISH.

• When the job is being processed by the job manager and the process manager, it is always in one of
these 5 states: 1. HOLD

2. READY

3. RUNNING

4. WAITING

5. FINISHED

Job and Process Status

1) HOLD - When a user submits a job and it accepts the job, the job is put on HOLD and placed in a
queue.

2) READY - A job is in READY state when it’s ready to run and waiting for the CPU.

3) RUNNING - When a job is in RUNNING state, it is being executed.

4) WAITING - When a job is in WAITING state, it means that the job can’t continue until a specified I/O
operation is done or a resource is allocated.

5) FINISHED - When a job is in FINISHED state, it means that the job is done and the output will be
returned to the user.

Transition among Job and

Process States

The transition from:

1. HOLD to READY is done by the job scheduler according to availability of main memory space and
some specific policies.

2. READY to RUNNING is done by the process scheduler (to decide which job will be done first)
according to some algorithms (e.g. FCFS).
3. RUNNING back to READY is done by process scheduler according to some criterion (e.g. Priority
Interrupt).

4. RUNNING to WAITING is done by process scheduler when some I/O request is encountered in the job
itself or some resource allocation is required.

5. WAITING to READY is done by the process scheduler when the requirements needed by the jobs are
satisfied (I/O request satisfied).

6. RUNNING to FINISHED is done by the process scheduler.

Process Control Block (PCB)

• Process Control Block (PCB) - data structure that contains basic info about the job

- Process identification

- Process status (HOLD, READY, RUNNING, WAITING, FINISHED)

- Process state (process status word, register contents, main memory info,

resources, process priority)

- Accounting (CPU time, total amount of time, I/O operations, number input records read)

PCBs and Queueing

• PCB of job created when Job Scheduler accepts it

- updated as job goes from beginning to termination.

• Queues use PCBs to track jobs.

- PCBs, not jobs, are linked to form queues.

- Example, PCBs for every ready job are linked on READY queue; all PCBs for jobs just entering system
are linked on HOLD queue. - Queues must be managed by process scheduling policies and algorithms.

Process Scheduling Policies

• Before operating system can schedule all jobs in a multiprogramming environment, it must resolve
three limitations of system:

- finite number of resources (such as disk drives, printers, and tape drives)

- some resources can’t be shared once they’re allocated (such as printers)

- some resources require operator intervention (such as tape drives).


Preemptive & Non-preemptive

• Preemptive scheduling policy interrupts processing of a job and transfers the CPU to another job.

• Non-preemptive scheduling policy functions without external interrupts.

- Once a job captures processor and begins execution, it remains in RUNNING state uninterrupted.

- Until it issues an I/O request or until it is finished.

Interrupts

• There are instances when a job claims CPU for a very long time before issuing an I/O request.

- Builds up READY queue & empties I/O queues.

- Creates an unacceptable imbalance in the system.

• Process Scheduler uses a timing mechanism to periodically interrupts running processes when a
predetermined slice of time has expired. - Suspends all activity on the currently running job and

reschedules it into the READY queue.

Process Scheduling Algorithms

• Scheduling algorithms, schedule processes on the processor in an efficient and effective manner.

• This scheduling is done by the Process Scheduler.

• It maximizes CPU utilization by increasing throughput.

• Following are the popular process scheduling algorithms:

1. First-Come, First-Served (FCFS) Scheduling

2. Shortest-Job-Next (SJN) or Shortest-Job-First (SJF) Scheduling 3. Round Robin (RR) Scheduling

• Terminologies to remember in Process Scheduling Algorithms.

✓ Arrival Time (AT): Time at which the process arrives in the ready queue. ✓ Completion Time (CT):
Time at which process completes its execution. ✓ Burst Time (BT): Time required by a process for CPU
execution. ✓ Turn Around Time (TAT): Time Difference between completion time and arrival time. ✓
Waiting Time (WT): Time Difference between start time and arrival time (Non-Preemptive Scheduling
Policy).

Time Difference between turn around time and burst time

(Preemptive Scheduling Policy) .


✓ Average Waiting Time (AWT): Sum of all waiting time divided by the number of processes.

First-Come First-Served (FCFS)

1. First-Come, First-Served (FCFS) Scheduling

- considered to be the simplest of all operating system scheduling algorithms. First come first serve
scheduling algorithm states that the process that requests the CPU first is allocated to the CPU first and
is implemented by using FIFO queue.

Characteristics of FCFS:

✓ FCFS supports non-preemptive and preemptive process scheduling algorithms.

✓ Tasks are always executed on a First-come, First-serve concept. ✓ FCFS is easy to implement and use.

✓ This algorithm is not much efficient in performance, and the wait time is quite high.

First-Come First-Served (FCFS)

Shortest Job Next (SJN)

2. Shortest Job Next (SJN) Scheduling

- also known as shortest job first (SJF), a scheduling algorithm that selects the waiting process with the
smallest burst time to execute next. Can be preemptive or non-preemptive.

Characteristics of SJN:

✓ SJN has the advantage of having a minimum average waiting time among all operating system
scheduling algorithm.

3. Round Robin (RR) Scheduling

- is the scheduling algorithm where each process is cyclically assigned a fixed time slot. It is the
preemptive version of FCFS Scheduling Algorithm. It generally focuses on the Time-Sharing technique.

Characteristics of RR:

✓ RR is simple, and starvation-free as all processes get the balanced CPU allocation.

✓ One of the most widely used methods in Process Scheduling ✓ Considered preemptive as the
processes are given to the CPU for a very limited time.

Chapter 5
Deadlock

• A lack of process synchronization can result in two extreme conditions:

- Deadlock

- Starvation

• A problem where resources needed by some process to finish execution are held by other processes,
which, in turn, are waiting for other resources to become available.

• Also called deadly embrace.

• Deadlock infrequent in batch systems, and more prevalent in interactive systems.

Seven Cases of Deadlock

• Case 1: Deadlocks on File Requests

• Case 2: Deadlocks in Databases

• Case 3: Deadlocks in Dedicated Device Allocation • Case 4: Deadlocks in Multiple Device Allocation •
Case 5: Deadlocks in Spooling

• Case 6: Deadlocks in a Network

• Case 7: Deadlocks in Disk Sharing

Case 1: Deadlocks on File Requests

Case 2: Deadlocks in Databases

Case 3: Deadlocks in Dedicated Device Allocation

1. P1 requests drive 1 and gets it.

2. P2 requests drive 2 and gets it.

3. P1 requests drive 2 but is blocked.


4. P2 requests drive 1 but is blocked.

Case 4: Deadlocks in Multiple Device Allocation

Case 5: Deadlocks in Spooling

• The spooler accepts output from several users and acts as a temporary storage area for all output
until the printer is ready to accept it.

• This process is called spooling.

Case 6: Deadlocks in a Network


Case 7: Deadlocks in Disk Sharing

Conditions for Deadlock

• Mutual exclusion

- act of allowing only one person (or process) to have access to a step (a dedicated resource)

• Resource Holding

- When two people meet on the stairs and each one holds ground and waits for the other to retreat

Conditions for Deadlock

• No Preemption

- Each step is dedicated to the climber; it is allocated to the holder for as long as needed.

• Circular Wait

- Each person (or process) involved in the impasse is waiting for another to voluntarily release the step
(or resource) so that at least one will be able to continue on and eventually arrive at the destination.

- Four conditions can be modeled using directed graphs.

Modeling Deadlocks Scenario #3:

Strategies for Handling Deadlocks

• Detection

• Prevention

• Avoidance

• Recovery

Detection
• The directed graphs presented earlier in this chapter showed how the existence of a circular wait
indicated a deadlock, so it’s reasonable to conclude that deadlocks can be detected by building
directed resource graphs and looking for cycles.

Prevention

• To prevent a deadlock, the operating system must eliminate one of the four necessary conditions, a
task complicated by the fact that the same condition can’t be eliminated

from every resource.

Avoidance

• Even if the operating system can’t remove one of the conditions for deadlock, it can avoid one if the
system knows ahead of time the sequence of requests associated with each of the active processes.

Recovery

• Once a deadlock has been detected, it must be untangled and the system returned to normal as
quickly as possible.

• There are several recovery algorithms, but they all have one feature in common: They all require at
least one victim, an expendable job, which, when removed from the deadlock, will free the system.

Starvation

• So far we have concentrated on deadlocks, the result of liberal allocation of resources.

• At the opposite end is starvation, the result of conservative allocation of resources where a single job
is prevented from execution because it’s kept waiting for resources that never become available.

Chapter 7
Basic Functions

• Monitoring the status of each device (storage drives, printers, etc.) • Enforcing present policies

- determine which process will get a device and for how long • Allocating the devices

• Deallocating them at two levels

- Process (task) level

- Job level

Types of Devices

• Dedicated Devices

• Shared Devices
• Virtual Devices

Types of Devices

• Dedicated Devices

- assigned to only one job at a time

- serve that job for the entire time it’s active or until it releases them

• Examples:

- Tape drives

- Printer

- Scanner

- Plotters

• Shared Devices

- can be assigned to several processes

• Example:

- Direct Access Storage Device (DASD)

- can be shared by several processes at the same time by interleaving their requests.

• Virtual Devices

- a combination of dedicated and shared devices.

- they’re dedicated devices that have been transformed into shared devices.

• Example:

- a printer converted into sharable devices through a spooling program

- Spooling program reroutes all print requests to a disk

• Universal Serial Bus (USB) Controller

- acts as an interface between the OS, device drivers, and applications attached via USB host.

- One USB host can accommodate up to 127 different devices - Devices can be flash memory, cameras,
scanners, musical keyboards. - Each devices is identified by the USB host controller with a unique
identification number, that allows many devices to exchange data with the computer using the same
USB connection.

Storage Media

• A physical device that receives, stores, and allows users and programs to access electronic data.

• The storage media might be inside a computer or other device or attached to a system externally,
either directly or over a network.

• Example:

- CD ROM, DVD ROM, DAT tape, DLT tape, disk drives, SSD, Flash Drive.

• Storage media are divided into two groups:

- Sequential Access Storage Media

- store records sequentially, one after the other

- Direct Access Storage Devices (DASD) - store either sequential or direct access files

• There are vast differences in their speed and shareability.

Sequential Access Storage Media

Magnetic tape

• Developed for routine secondary storage in early computer systems and features records that are
stored serially, one after other.

• The length of these records is usually determined by the application program and each record can be
identified by its position on the tape. • To access a single record, the tape must be mounted and fast-
forwarded until the desired position is located.

Sequential Access Storage Media

• Let’s consider a hypothetical computer system that uses a reel tape that is 2400 feet long.
Density of the Tape

• Determined by the number of characters that can be recorded per inch, such as (1600 bpi).

• Bytes per inch (bpi)

• For example, if you had records of 160 characters each, and were storing them on a tape with a
density of 1600 bpi, then you can store 10 records on one inch of tape.

• Records can be stored individually or grouped into blocks: • If the records are stored individually, each
record would need to be separated by a space to indicate its starting and ending places. • If the records
are stored in blocks

- Preceded by a space

- Followed by a space

- Individual records are stored sequentially within the block. • Blocking

- Way of grouping the record into blocks before recording them on tape.

- The number of records in a block is determined by the application program.


Transfer Rate

- The rate at which data is transferred from sequential access media

- Density of the tape (measured in bpi), multiplied by tape drive speed (transport speed)

- Can be measured in inches per second (ips)

Sequential Access Storage Media

- Transfer Rate (ips) = density * transport speed.

Example:

- Transport Speed is 200

- Density is 1600 bpi

- Transfer Rate = 1600 * 200

- Transfer Rate = 320,000 bytes can be transferred in one second.

• How long does it take to access a block or record on magnetic tape? - depends on where the record is
located, can be calculated.

• For example, our 2400-foot reel of tape with a tape transport speed of 200 ips can be read without
stopping in approximately 2.5 minutes.

• Therefore, it would take 2.5 minutes to access the last record on the tape. • On the average, then, it
would take 1.25 minutes to access a record. And to access one record after another sequentially would
take as long as it takes to start and stop a tape - which is 0.003 seconds, or 3 milliseconds (ms).

• Access Time

- Total time required to access data in secondary storage.


Device Management (Part 2)

Chapter 7

Storage Media

• Storage media are divided into two groups: ○ Sequential Access Storage Media

- store records sequentially, one after the other ○ Direct Access Storage Devices (DASD)

- store either sequential or direct access files • There are vast differences in their speed and
shareability.

Direct Access Storage Devices (DASD)

• Devices that can directly read or write to a specific place.

• Grouped into 3 categories:

- Magnetic disks (Fixed-Head, Movable-Head)

- Optical discs

- Flash memory

• Although the variance in DASD access times isn’t as wide as with magnetic tape, the location of the
specific record still has a direct effect on the amount of time required to access it.
Fixed-Head Magnetic Disk Storage

• Looks like CD or DVD covered with magnetic film that has been formatted.

• Each circle is called track.

• Data is recorded serially on each track by the fixed read/write head position over it.

Direct Access Storage Devices (DASD)

Fixed-Head Magnetic Disk Storage

• Faster than movable-head disks

• Used when speed is of the utmost

importance

• High costs

• Reduced storage space compare to

○ movable disk

Movable-Head Magnetic Disk Storage

• Like a computer hard drives.

• Have one read/write head that floats over each surface of each disk. • Disk can be a single platter or
part of a disk pack/stack of magnetic platters.

• The number of tracks typically a thousand or more


Movable-Head Magnetic Disk Storage

Each platter has two surfaces for recording, and each surface is formatted with a specific number of
concentric tracks where the data is recorded. Each track on each surface is numbered:

Track 0 identifies the outermost concentric circle on each surface; the highest-numbered track is in the
center

Movable-Head Magnetic Disk Storage

The arm moves two read/write heads between each pair of surfaces: 1 surface above and 1 surface
below.

The arm moves all of the heads in unison, so if one head is on Track 36, then all of the heads are on
Track 36 - in other words, they’re all positioned on the same track but on their respective surfaces
creating a virtual cylinder.
Movable-Head Magnetic Disk Storage
Optical Disc Storage

• Was made possible by developments in laser technology. • Single spiraling track of same-sized
sectors.

• Running from the center to the rim of the disc.

Optical Disc Storage

Optical disc consists of a single spiraling track of same-sized sectors running from the center to the
rimof the disc.

• To put data on an optical disc, a high-intensity laser beam burns indentations on the disc that are
called pits.

• These pits, which represent 0s, contrast with the unburned flat areas, called lands, which represent
1s.

• The first sectors are located in the center of the disc the laser moves outward reading each sector in
turn.
Optical Disc vs Magnetic Disk

• Among the many differences between an optical disc and a magnetic disk is the design of the disc
track and sectors.

• A magnetic disk, which consists of concentric tracks of sectors, spins at a constant speed—this is
called constant angular velocity (CAV). • Because the sectors at the outside of the disk spin faster past
the read/write head than the inner sectors, outside sectors are much larger than sectors located near
the center of the disk.

• On the other hand, an optical disc consists of a single spiraling track of same-sized sectors running
from the center to the rim of the disc. • This single track also has sectors, but all sectors are the same
size regardless of their locations on the disc.

• The disc drive adjusts the speed of the disc’s spin to compensate for the sector’s location on the disc
—this is called constant linear velocity (CLV).

Flash Memory Storage

• A type of electrically erasable programmable read-only memory (EEPROM).

• A nonvolatile removable medium that emulates random access memory, but, unlike RAM, stores data
securely even when it’s removed from its power source.

• Historically, flash memory was primarily used to store startup (boot up) information for computers,
but is now used to store data for cell phones, mobile devices, music players, cameras, and more.

• The bits can be erased only by applying the flash to a large block of memory with each flash erasure,
the block becomes less stable.

• In time (after 10,000 to 1,000,000 uses), a flash memory device will no longer reliably store data.

• Examples:

- USB flash drives

- SSDs

- Memory cards,

- Smartphones, tablets, etc.

File Management Chapter 8


The File Manager

• File Manager is also called the File Management System and is the software responsible for:

- Creating, deleting, modifying, controlling access to files


• Provides support for libraries of programs to online users, for spooling operation, and for interactive
computing.

File Concept

• Files are the building blocks of any operating system. Permanent storage of information & data.

• OS is not interested in what information is stored in file. OS maps files with physical devices.

• User prepare a program (file), File represent program and data. The output of program is called
executable file.

File Access Methods

• 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 File Access

• Direct File Access

• Indexed File Access

Access Methods: Sequential File Access

• Is a method of accessing data sequentially/one record at a time by starting from the beginning of the
file to its end.

• This access method is the most primitive and straightforward method of accessing files.

• Advantage: simple, easy to implement and use.

• Disadvantage: slow and inefficient for random access operations or when working with large files

Access Methods: Direct File Access

• Also known as Random file access.

• Allows users to access data directly from any location within the file without the need to
read/writeall the records that come before it.

• Advantage: speed and efficiency for random access operations.

• Disadvantage: more complex and difficult to implement and use than sequential file access.
Access Methods: Indexed File Access

• Is a method that incorporates the benefits of both sequential and direct file access.

• Creating an index file that maps logical keys or data elements to their corresponding physical
addresses within the file.

• Index is searched sequentially and its pointer is used to access the file directly.

• Advantage: speed and efficiency for random and sequential access operations.

• Disadvantage: requires additional storage for the index, increase the cost and complexity of the
system.

File types

• 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

• Directory files

• Special files

File types: Ordinary Files

• These are the files that contains 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.

File types: Directory Files

• Directory files contains list of file and other related information to those files.

• Also known as “folders” in other operating systems. • Folders that holds and organize multiple files.

File types: Special Files

• These files are also known as device files.

• Represents physical devices 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 Operations

• Create: The file is created with no data.

• Delete: File must has to be deleted when it is no longer needed just to free up the disk space.

• Open: The process must open the file before using it.

• Close: The file must be closed to free up the internal table space, when all the accesses are finished
and the attributes and the disk addresses are no longer needed.

• Read: The file read operation is performed just to read the data that are stored in the required file.

File Operations

• Write: The file write operation is used to write the data to the file, again, generally at the current
position.

• Append: The file append operation is same as the file write operation except that the file append
operation only add the data at the end of the file.

• Seek: For random access files, a method is needed just to specify from where to take the data.
Therefore, the file seek operation performs this task.

• Rename: The file rename operation is used to change the name of the existing file.

Directory Structure

• Directory

is a list of files that stores all the related information about the file it hold with the contents. Directory is
a list of files.

Each entry of a directory define a file information like a file name, type, its version number, size ,owner
of file, access rights, date of creation and date of last backup.

• Types:

1. Single-level directory structure

2. Two-level directory structure

3. Tree-structured directory structure

1. Single-level directory structure

- in a single level directory system, all the files are placed in one directory

Directory Structure

2. Two-level directory structure

- in the two-level directory system, the system maintains a master block that has one entry for each
user.
3. Tree-structured directory structure

- in the tree-structured directory, the directory themselves are files. This files to the possibility of having
sub-directories that can contain files and sub-subdirectories

File Management System Structure

● Layered File System

- there are 6 layers

File Management System Structure

• Application Program Layer:

- user creates application program

• Logical File System Layer:

- manages the meta data information

• File Organization Module Layer:

- maintain information about file

File Management System Structure

• Basic File System Layer:

- generate command for device driver

- also manage buffer memory and cache

• I/O Control Interface Layer:

- it consists of device driver & interrupt handler.

- transfer data: between main memory to disk system.

• Physical Hardware Device Layer:

- contain actual hardware device

Data Compression

• A reduction in the amount of bits required to represent data is known as data compression.

• Compressing data can save storage capacity, speed up file transfer and decrease costs for storage
hardware and network bandwidth.
How compression works

• Compression is performed by a program that uses a formula or algorithm to determine how to shrink
the size of the data. • For instance, an algorithm may represent a string of bits -- or 0s and 1s -- with a
smaller string of 0s and 1s by using a dictionary for the conversion between them.

• When information is sent or received via the internet, larger files -- either singly or with others as part
of an archive file -- may be transmitted in a ZIP, GZIP or other compressed format.

You might also like