You are on page 1of 24

Presented By

Firoz Mahmud
Assistant Professor
Dept. of Computer Science & Engineering
Rajshahi University of Engineering & Technology
 Computer-system operation
– One or more CPUs, device controllers connect through
common bus providing access to shared memory
– Concurrent execution of CPUs and devices competing
for memory cycles
 I/O devices and the CPU can execute concurrently
 Each device controller is in charge of a particular device
type
 Each device controller has a local buffer
 CPU moves data from/to main memory to/from local
buffers
 I/O is from the device to local buffer of controller
 Device controller informs CPU that it has finished its
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
 Interrupt architecture must save the address of the
interrupted instruction
 A trap or exception is a software-generated interrupt
caused either by an error or a user request
 An operating system is interrupt driven
 After I/O starts, control returns to user program only upon I/O
completion
 Wait instruction idles the CPU until the next interrupt
 Wait loop (contention for memory access)
 At most one I/O request is outstanding at a time, no simultaneous I/O
processing
 After I/O starts, control returns to user program without waiting for
I/O completion
 System call – request to the OS 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 I/O device table to determine device status and to
modify table entry to include interrupt
 Main memory – only large storage media that the CPU can access directly
 Random access
 Typically volatile
 Secondary storage – extension of main memory that provides large
nonvolatile storage capacity
 Hard disks – rigid metal or glass platters covered with magnetic recording
material
Disk surface is logically divided into tracks, which are subdivided into sectors
The disk controller determines the logical interaction between the device and
the computer
 Solid-state disks – faster than hard disks, nonvolatile
 Various technologies
 Becoming more popular
 Storage systems organized in hierarchy
 Speed
 Cost
 Volatility
 Caching – copying information into faster storage system; main
memory can be viewed as a cache for secondary storage
 Device Driver for each device controller to manage I/O
 Provides uniform interface between controller and kernel
 Important principle, performed at many levels in a computer (in
hardware, operating system, software)
 Information in use copied from slower to faster storage
temporarily
 Faster storage (cache) checked first to determine if information
is there
 If it is, information used directly from the cache (fast)
 If not, data copied to cache and used there
• Cache smaller than storage being cached
 Cache management important design problem
 Cache size and replacement policy
• In a hierarchical storage structure, the same data may
appear in different levels of the storage system.
• For example,

To be
incremented
by 1
• The increment operation proceeds by first issuing an I/0
operation to copy the disk block on which A resides to main
memory.
• This operation is followed by copying A to the cache and to an
internal register.
• Thus, the copy of A appears in several places: on the magnetic
disk, in main memory, in the cache, and in an internal register.

Fig: Migration of integer A from disk to register.


• Once the increment takes place in the internal register,
the value of A differs in the various storage systems.
• In Batch system there will no problem, due to the integer
A will always be to the copy at the highest level of the
hierarchy.
• Problem 1: Multitasking environment, where the CPU
is switched back and forth among various processes.
 Extreme care must be taken to ensure that, if
several processes wish to access A, then each of
these processes will obtain the most recently
updated value of A.
• Problem 2: In multiprocessor environment where, in
addition to maintaining internal registers, each of the
CPUs also contains a local cache.
• Extreme care must be taken to ensure that, if several
processes wish to access A, then each of these
processes will obtain the most recently updated value of
A.
• A copy of int A may exist simultaneously in several
caches.
• Since the various CPUs can all execute concurrently, we must
make sure that an update to the value of A in one cache is
immediately reflected in all other caches where A resides.
• Problem 3: Distributed environment--> becomes even
more complex.
• Several copies (or replicas) of the same file can be kept
on different computers that are distributed in space.
• Since the various replicas may be accessed and
updated concurrently, we must ensure that, when a
replica is updated in one place, all other replicas are
brought up-to-date as soon as possible.

• This situation is called cache coherency.


 Dual-mode operation allows OS to protect itself and other system
components
 User mode and kernel mode (also known as Monitor, Supervisor,
System Mode)
 Mode bit provided by hardware
Provides ability to distinguish when system is running user code or
kernel code
Mode bit 1 for user and 0 for Kernal
Some instructions designated as privileged, only executable in
kernel mode
System call changes mode to kernel, return from call resets it to
user
 Increasingly CPUs support multi-mode operations
 i.e. virtual machine manager (VMM) mode for guest VMs
 A process is a program in execution. It is a unit of work within
the system. Program is a passive entity, process is an active
entity.
 Process needs resources to accomplish its task
 CPU, memory, I/O, files, Initialization data
 Process termination requires reclaim of any reusable resources
 Single-threaded process has one program counter specifying
location of next instruction to execute
 Process executes instructions sequentially, one at a time,
until completion
 Multi-threaded process has one program counter per thread
 Typically system has many processes, some user, some
operating system running concurrently on one or more CPUs
The operating system is responsible for the following
activities in connection with process management:

 Creating and deleting both user and system


processes
 Suspending and resuming processes
 Providing mechanisms for process synchronization
 Providing mechanisms for process communication
 Providing mechanisms for deadlock handling
 To execute a program all (or part) of the instructions must be in
memory
 All (or part) of the data that is needed by the program must be
in memory.
 Memory management determines what is in memory and when
 Optimizing CPU utilization and computer response to users
 Memory management activities
 Keeping track of which parts of memory are currently being used and by
whom
 Deciding which processes (or parts thereof) and data to move into and
out of memory
 Allocating and deallocating memory space as needed
 File-System management
 Files usually organized into directories
 Accesscontrol on most systems to determine
who can access what
 OS activities include
Creating and deleting files and directories
Primitives to manipulate files and directories
Mapping files onto secondary storage
Backup files onto stable (non-volatile) storage media
 Operating systems provide an environment for execution of programs
and services to programs and users
 One set of operating-system services provides functions that are helpful
to the user:
 User interface - Almost all operating systems have a user interface
(UI).
 Varies between Command-Line (CLI), Graphics User Interface
(GUI), Batch
 Program execution - The system must be able to load a program
into memory and to run that program, end execution, either normally
or abnormally (indicating error)
 I/O operations - A running program may require I/O, which may
involve a file or an I/O device
 Operating systems provide an environment for execution of programs
and services to programs and users
 One set of operating-system services provides functions that are helpful
to the user:
 User interface - Almost all operating systems have a user interface
(UI).
 Varies between Command-Line (CLI), Graphics User Interface
(GUI), Batch
 Program execution - The system must be able to load a program
into memory and to run that program, end execution, either normally
or abnormally (indicating error)
 I/O operations - A running program may require I/O, which may
involve a file or an I/O device
 One set of operating-system services provides functions that are helpful to the user
(Cont.):
 File-system manipulation - The file system is of particular interest. Programs
need to read and write files and directories, create and delete them, search
them, list file Information, permission management.
 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 - When multiple users or multiple jobs running
concurrently, resources must be allocated to each of them
 Many types of resources - CPU cycles, main memory, file storage,
I/O devices.
 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

You might also like