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

CSC 504 - Lecture Series I - Revision oCT 31 2023

Uploaded by

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

CSC 504 - Lecture Series I - Revision oCT 31 2023

Uploaded by

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

CSC 504- OPERATING SYSTEMS 2

BY
OLADEJI F.A.
DEPARTMENT OF COMPUTER SCIENCES
UNIVERSITY OF LAGOS
2023
COURSE CONTENTS
• Advanced concepts in process synchronization:
– distributed systems: architecture, theoretical foundation
– distributed file systems
– distributed coordination of processes
– mutual exclusion, deadlock
– agreement protocols
– distributed resource management- file systems, shared
memory, scheduling and mass storage
– Fault Tolerance and recovery
– Protection and security
Course materials
• Operating systems fundamentals by C.O. Uwadia, Oladeji F.A.,
Willams G. (at the bookshop)
• Abraham Silberschatz, Peter Baer Galvin, and Greg Gagne
(2013). Operating Systems Concepts, 7th Edition, John Wiley &
Sons Inc
• Jean Bacon & Tim Harris (2003), Operating Systems, Concurrent
and Distributed Software Design, Pearson Education Publishers.
• William Stallings (2005), Operating Systems, Internals & Design
principles, fifth edition, Pearson Hall.
• Gary Nutt (2003), Operating Systems, third edition. Addison
Wesley.
Course Grading System
• CA 30%
– Test (Every Week) 10%
– Group Assignment 10%
– Practical (individual) 10%
• EXAM 70%
– Multiple choice and theory
Mind this !!!!!!
• Absent from lecture is an offence
• Not participating in group work is an offence
• Late submission is an offence
• Ensure you are within the environment of
Internet of the University if you don’t have
data to connect e.g. science, senate,
GTB/Zenith or computer science library to gain
maximally.
Activity 1
• Divide yourselves to groups of 8
• Read the chapter 1 of the main text (already
sent to you) and let each group come up with
one page of summary of the chapter.
• Always list your group member as page 1 and
page 2 for the attempt to the summary
• Note that copying verbatim is a great offence
as it earns you zero
OS – an indispensable system program
• For booting after the BIOS run, loads residents
programs, hands over to users
• Depending on user’s operation, OS keeps track of how
much, who use, when, for what of these resources:
memory, processor (s), file, IO devices
• In case of contention among processes, OS releases
these resources and prevent illegal hanging of systems
• OS allows for evolution of both software and hardware
• OS relieves human of direct interaction with hardware
• Etc.
OS as a resource manager
• Process management module:-sees to process creation, process data structure
(PCB), state transitions, process interactions, scheduling and interrupt handling
• Memory management module:- process loading, swapping, memory
preparation, address resolution, enforce memory policy, coalescing,
• Device management module:-Accepts driver to install devices, keeps and
maintains the system bus, the multiple bus, sensitive to data transfer in/out
memories, observes a particular technique to manage I/Os,
setting/configuration of parameters etc
• File management systems- creation, organization of files, accessing of files,
deletion (ZAP), directories
• Network/Distributed management module: protocol setting, NIC setting,
browser loading, document transfer
• Concurrency management system:- inter-processor communications, reusable
devices, deadlock prevention, process synchronization etc.
Definitions
• OS is a suit of programs that manages the
computer systems- hardware, software
resources
• It acts as intermediary between the user,
application programs and the hardware
• An indispensable component of any computer
system
Resources
A View of Operating System Services
OS placement
Goals of OS
• OS has these objectives:
• Convenience: An OS makes a computer more
convenient to use.
• Efficient Resource usage: An OS allows the
computer system resources to be used in an
efficient manner.
• Ability to evolve: An OS should be constructed in
such a way as to permit the effective development,
testing, and introduction of new system functions
without interfering with service
– Resource allocation – When multiple users or
multiple jobs running concurrently, resources must be
allocated to each of them
• Many types of resources - Some (such as CPU cycles, main
memory, and file storage) may have special allocation code,
others (such as I/O devices) may have general request and release
code
• Accounting - To keep track of which users use how much and
what kinds of computer resources
• Protection and security - The owners of information stored in a
multiuser or networked computer system may want to control
use of that information, concurrent processes should not interfere
with each other
– Protection involves ensuring that all access to system resources is
controlled
– Security of the system from outsiders requires user authentication,
extends to defending external I/O devices from invalid access
attempts
– If a system is to be protected and secure, precautions must be
instituted throughout it. A chain is only as strong as its weakest link.
– Communications – Processes may exchange
information, on the same computer or between
computers over a network
• Communications may be via shared memory or through message
passing (packets moved by the OS)
– Error detection – OS needs to be constantly aware
of possible errors
• May occur in the CPU and memory hardware, in I/O devices, in user
program
• For each type of error, OS should take the appropriate action to
ensure correct and consistent computing
• Debugging facilities can greatly enhance the user’s and
programmer’s abilities to efficiently use the system

• Another set of OS functions exists for ensuring


the efficient operation of the system itself via
resource sharing – Resource allocation
– Communications – Processes may exchange
information, on the same computer or between
computers over a network
• Communications may be via shared memory or through message
passing (packets moved by the OS)
– Error detection – OS needs to be constantly aware
of possible errors
• May occur in the CPU and memory hardware, in I/O devices, in user
program
• For each type of error, OS should take the appropriate action to
ensure correct and consistent computing
• Debugging facilities can greatly enhance the user’s and
programmer’s abilities to efficiently use the system

• Another set of OS functions exists for ensuring


the efficient operation of the system itself via
resource sharing – Resource allocation
Managing the Process-PMM
• One of the fundamental tasks of any modern operating
system is process management.
– The operating system must allocate resources to created
processes,
– enable processes to share and exchange information,
– protect the resources of each process from other processes,
and
– enable synchronization among processes.
• To meet these requirements, the operating system must
maintain a data structure for each process that describes
the state and resource ownership of that process.
Resources vs resource data structures
Definition of a Process
• A program in execution
• An instance of a program running on a computer
• The entity that can be assigned to and executed
on a processor
• A unit of activity characterized by the execution of
a sequence of instructions
• Two essential elements of a process are program
code and a set of data associated with that code
Process Data Structure-> PCB
• A process is characterized by a number of elements which include:
• Identifier: A unique identifier associated with this process, to distinguish it
• from all other processes.

• State: If the process is currently executing, it is in the running state.


• Priority: Priority level relative to other processes.

• Program counter: The address of the next instruction in the program to be


• executed.
• Memory pointers: Includes pointers to the program code and data associated
• with this process, plus any memory blocks shared with other processes.
• Context data: These are data that are present in registers in the processor
• while the process is executing.

• I/O status information: Includes outstanding I/O requests, I/O devices (e.g., tape drives)
assigned to this process, a list of files in use by the process.
• Accounting information: May include the amount of processor time and clock
• time used, time limits
OS and a Process
• OS keeps track of a process by
– Getting it loaded to the RAM(Buffering)
– Deciding which process in the RAM is to have the
processor (scheduling or dispatching)
– While executing, OS monitors the PCB information about
the process
– Managing swapping/activating blocked processes
• OS monitors which process use the processor, for
how long and which resource is used by the process
Flow of a Created Process
Blocking of a Process
5-State model
Process States
• New: A process that has just been created but has not yet been
admitted to the RAM even though its process control block has
been created.

• Running: The process that is currently being executed.

• Ready: A process that is prepared to execute when given the


opportunity.

• Blocked/Waiting: A process that cannot execute until some event


occurs, such as the completion of an I/O operation

• Exit: A process that has been released from the pool of executable
processes by the OS, either because it halted or because it aborted
for some reason or completed
Interleaving of Processes
(1 processor many processes)
Five-state model extension
Reasons for process suspension
Operations on a Process
• Creation (spawning)
• Process scheduling or dispatching
• Swapping in and out of RAM and Virtual RAM
• Deletion /termination (kill or end process)- Task
management
• Process migration
• Process blocking/suspension
• Resuming/waking up a blocked/suspended process
• Change a process priority or address space
Reason for creating processes
Process Scheduling
• The choice of which process among ready processes for
execution is called process dispatching or scheduling
• Efficiency of the OS on this determines the utilization of
the processor, hence the performance
• The objectives of scheduling include:
– maximize the system throughput.
– be ‘fair’ to all users.
– provide tolerable response time for on-line users and turn­
around time for batch users.
– degrade performance gracefully under heavy loading.
Dispatch approaches
• FIFO
– Follow order of arrival into the queue
– Favours long jobs : CPU-bound vs I/O-bound jobs
– It is not useful in a time sharing environment
because it cannot guarantee a good response time.
• Shortest Job First(SJF)
• Shortest Remaining Time (SRT)
• Round Robin (RR)
• Priority
– Static )non-preemptive
– Rate-based (preemptive)
OS -> MMM

• To provide a detailed description of various


ways of organizing memory hardware
• To discuss various memory-management
techniques, including paging and segmentation
• To provide a detailed description of the Intel
Pentium, which supports both pure
segmentation and segmentation with paging
Process and memory cells

• Program must be brought (from disk) into memory and placed


within a process for it to be run
• Main memory and registers are only storage CPU can access
directly
• Memory unit only sees a stream of addresses + read requests, or
address + data and write requests
• Register access in one CPU clock (or less)
• Main memory can take many cycles, causing a stall
• Cache sits between main memory and CPU registers
• Protection of memory required to ensure correct operation
• A pair of base and limit registers define the logical address space
• CPU must check every memory access generated in user mode to
be sure it is between base and limit for that user
Contiguous Allocation

• Main memory must support both OS and user


processes
• Limited resource, must allocate efficiently
• Contiguous allocation is one early method
• Main memory usually into two partitions:
– Resident operating system, usually held in low
memory with interrupt vector
– User processes then held in high memory
– Each process contained in single contiguous section
of memory
Contiguous Allocation

• Relocation registers are used to protect user


processes from each other, and from changing
operating-system code and data
– Base register contains value of smallest physical
address
– Limit register contains range of logical addresses –
each logical address must be less than the limit
register
– MMU maps logical address dynamically
Multiple-partition allocation

• Multiple-partition allocation
– Degree of multiprogramming limited by number of partitions
– Variable-partition sizes for efficiency (sized to a given process’ needs)
– Hole – block of available memory; holes of various size are scattered throughout memory
– When a process arrives, it is allocated memory from a hole large enough to accom=modate it
– Process exiting frees its partition, adjacent free partitions combined
– Operating system maintains information about:
a) allocated partitions b) free partitions (hole)
Dynamic Storage-Allocation Problem

How to satisfy a request of size n from a list of free holes?

• First-fit: Allocate the first hole that is big enough

• Best-fit: Allocate the smallest hole that is big


enough; must search entire list, unless ordered by
size
– Produces the smallest leftover hole

• Worst-fit: Allocate the largest hole; must also


First-fitsearch entire
and best-fit listthan worst-fit in terms of speed and storage
better
– Produces the largest leftover hole
utilization
Fragmentation

• External Fragmentation – total memory space


exists to satisfy a request, but it is not
contiguous
• Internal Fragmentation – allocated memory
may be slightly larger than requested memory;
this size difference is memory internal to a
partition, but not being used
• Reduce external fragmentation by compaction
– Shuffle memory contents to place all free
memory together in one large block
– Compaction is possible only if relocation is
dynamic
Segmentation

• Memory-management scheme that supports user view of


memory
• A program is a collection of segments
– A segment is a logical unit such as:
main program
procedure
function
method
object
local variables, global variables
common block
stack
symbol table
arrays
Segmentation Architecture

• Logical address consists of a two tuple:


<segment-number, offset>,
• Segment table – maps two-dimensional physical
addresses; each table entry has:
– base – contains the starting physical address where the
segments reside in memory
– limit – specifies the length of the segment
• Segment-table base register (STBR) points to the
segment table’s location in memory
• Segment-table length register (STLR) indicates
number of segments used by a program
segment number s is legal if s < STLR
Paging

• Physical address space of a process can be noncontiguous;


process is allocated physical memory whenever the latter is
available
– Avoids external fragmentation
– Avoids problem of varying sized memory chunks
• Divide physical memory into fixed-sized blocks called frames
– Size is power of 2, between 512 bytes and 16 Mbytes
• Divide logical memory into blocks of same size called pages
• Keep track of all free frames
• To run a program of size N pages, need to find N free frames
and load program
• Set up a page table to translate logical to physical addresses
• Backing store likewise split into pages
• Still have Internal fragmentation
Implementation of Page Table

• Page table is kept in main memory


• Page-table base register (PTBR) points to the page
table
• Page-table length register (PTLR) indicates size of
the page table
• In this scheme every data/instruction access
requires two memory accesses
– One for the page table and one for the data /
instruction
• The two memory access problem can be solved by
the use of a special fast-lookup hardware cache
called associative memory or translation look-
aside buffers (TLBs)
Intel x86-64
 Current generation Intel x86 architecture
 64 bits is ginormous (> 16 exabytes)
 In practice only implement 48 bit addressing
 Page sizes of 4 KB, 2 MB, 1 GB
 Four levels of paging hierarchy
 Can also use PAE so virtual addresses are 48 bits and physical
addresses are 52 bits
I-O Module
• The Input-Output (I/O) system is one of the four pillars on which
the computer system rests.
• The processor, the main memory, the I/O and the file systems
constitute main elements to perfect the process of computation.
• The I/O system is the least satisfactory member of the four
because of its relative slowness which are a consequence of the
nature of I/O devices.
• These are external devices connected to the main CPU through
serial or parallel ports.
• An I/O module is required to perform the following two functions:
– Interface to the processor and memory via the system bus.
– Interface to one or more peripheral devices by tailored data links.

11/15/2024 Department of Computer Sciences, U 45


NILAG
Multi-bus Organization

11/15/2024 Department of Computer Sciences, U 46


NILAG
Block Diagram of an External device

11/15/2024 Department of Computer Sciences, U 47


NILAG
An I-O setup

11/15/2024 Department of Computer Sciences, U 48


NILAG
I-O Categories
• External devices that engage in I/O with computer systems
can be roughly grouped into three categories:
• Human readable: Suitable for communicating with the
computer user. Examples include printers and terminals,
the latter consisting of video display, keyboard, and
perhaps other devices such as a mouse.
• Machine readable: Suitable for communicating with
electronic equipment. Examples are disk drives, USB keys,
sensors, controllers, and actuators.
• Communication: Suitable for communicating with remote
devices. Examples are digital line drivers and modems.
11/15/2024 Department of Computer Sciences, U 49
NILAG
I-O Channels/Controller
• I/O module varies considerably in complexity and the number of external
devices that they control
• The module connects devices to the rest of the computer through a set of
signal lines (e.g., system bus lines).
• Data transferred to and from the module are buffered in one or more data
registers.
• There may also be one or more status registers that provide current status
information. A status register may also function as a control register, to
accept detailed control information from the processor.
• The logic unit within the module interacts with the processor via a set of
control lines. The processor uses the control lines to issue commands to the
I/O module. Some of the control lines may be used by the I/O module to
pass information back to the CPU
• An I/O module that takes on most of the detailed processing burden off the
CPU, presenting a high-level interface to theCPU, is usually referred to as an
I/O channel or I/O processor
11/15/2024 Department of Computer Sciences, U 50
NILAG
Assessing I-O Devices
• Data Rate: Amount of bits movement per unit
of time

11/15/2024 Department of Computer Sciences, U 51


NILAG
Assessment…
• Device Application:
• The use to which a device is put has an influence on the software
and policies in the operating system and supporting utilities.
• For example, a disk used for files requires the support of file
management software.
• The use of a network printer is different from a single user printer:
has a higher buffer/pool, requires queue management and
synchronization, may have its own IP address
• A MODEM does modulation and demodulation processes to realize
data communication. Requires support utility e.g. the protocols
• Most devices are slow compared to processor speed, thereby
require controllers to mediate i.e. speed mismatch problem

11/15/2024 Department of Computer Sciences, U 52


NILAG
Assessment…
• Complexity of control:
• A printer requires a relatively simple control
interface.
• A disk is much more complex (head
placement). The effect of these differences
on the operating system is filtered to some
extent by the complexity of the I/O module
that controls the device.
• A- tracks, B-cylinder C-sector D-block or
cluster
11/15/2024 Department of Computer Sciences, U 53
NILAG
I-O Functions
• The major functions or requirements for an I/O module fall into
the following categories:
– Control and timing
– Processor communication
– Device communication
– Data buffering
– Error detection
• I-O module mediates between the CPU and I/O devices.
• Note that each device has a small processing unit called controller
with small memory to hold its working data called the buffer
• I/O module communicates with the processor and with available
external devices through the system bus

11/15/2024 Department of Computer Sciences, U 54


NILAG
Processor-Device communication
• Processor communication involves the following:
• Command decoding: The I/O module accepts commands from the processor,
typically sent as signals on the control bus. For example, an I/O module for a disk
drive might accept the following commands: READ SECTOR, WRITE SECTOR, SEEK
track number, and SCAN record ID.
• Data exchange: Data are exchanged between the processor and the I/O module
over the data bus.
• Status reporting: Because peripherals are so low, it is important to know the status
of the I/O module. For example, if an I/O module is asked to send data to the
processor (read), it may not be ready to do so because it is still working on the
previous I/O command. This fact can be reported with a status signal. Common
status signals are BUSY and READY. There may also be signals to report various
error conditions.
• Address recognition: just as each word of memory has an address, so does each
I/O device. Thus, an I/O module must recognize one unique address for each
peripheral it controls. The address is called interrupt number
11/15/2024 Department of Computer Sciences, U 55
NILAG
I-O Data Buffering Function
• An essential task of an I/O module is data buffering.
• The transfer rate into and out of main memory or the processor is
quite high and faster than the device could handle.(speed mismatch)
• Data coming from main memory are sent to an I/O module in a rapid
burst. The data are buffered in the I/O module and then sent to the
peripheral device at its data rate.
• In the opposite direction, data are buffered so as not to tie up the
memory in a slow transfer operation.
• Thus, the I/O module must be able to operate at both device and
memory speeds.
• Similarly, if the I/O device operates at a rate higher than the memory
access rate, then the I/O module performs the needed buffering
operation better
11/15/2024 Department of Computer Sciences, U 56
NILAG
Error Detection Functions
• An I/O module is often responsible for error detection and for
subsequently reporting errors to the processor through OS.
• One class of errors includes mechanical and electrical malfunctions
reported by the device (e.g., paper jam, bad disk track). Another
class consists device to I/O module.
• Some form of error-detecting code is often used to detect
transmission errors.
• A simple example is the use of a parity bit on each character of data.
For example, the IRA character code occupies 7 bits of a byte. The
eight bit is set so that the total number of 1s in the byte is even
(even parity) or odd (odd parity).
• When a byte is received, the I/O module check the parity to
determine whether an error as occurred.
11/15/2024 Department of Computer Sciences, U 57
NILAG
I-O Management Techniques
• Three techniques are possible for I/O operations:
– Programmed I-O
– Interrupt-driven I-O
– Direct Memory Access (DMA)
• With programmed I/O, data are exchanged between the processor and the I/O
module. The processor executes a program that gives it direct control of the I/O
operation, including sending device status, sending a read or write command, and
transferring the data. When the processor issues a command to the I/O module, it
must wait until the I/O operation is complete. If the processor is faster than I/O
module, this is wasteful of processor time.
• With interrupt-driven I/O, the processor issues an I/O command, continues to execute
other instructions, and is interrupted by the I/O module when the latter has completed
its work. With both programmed and interrupt I/O, the processor is responsible for
extracting data from main memory for output and storing data in main memory for
output.
• The alternative is known as direct memory access (DMA). In this mode, the I/O module
and main memory exchange data directly, without processor involvement.
11/15/2024 Department of Computer Sciences, U 58
NILAG

You might also like