Professional Documents
Culture Documents
Computer Science
Operating Systems
An operating system is a program or a set of programs that enables communication
between a user, hardware and application software. It is the first program loaded
into the computer and remains in memory at all times. The operating system is
responsible for providing the interface between a particular device and a user,
allocating memory, recognizing input from external devices and transmitting output
to computer displays. It also acts as a resource manager, manages files on the
computer hard drives and controls peripherals like printers and scanners.
Kernel Mode: Also known as supervisor mode, gives complete access to all the
hardware and can execute any instruction the computer is capable of executing.
User Mode: Only a minimal set of instructions are available.
E.g. of OS: Windows [Dos], Linux, UNIX, Solaris
Features of OS
1. Defines the user interface
2. Shares hardware among the users
3. Facilitates input and output
4. Schedules resources among users
5. Allows users to share data amongst themselves
6. Recover from errors
Job = Program
Process = Program being executed
Batch OS
In a Batch system, a tray full of jobs were collected and written onto a magnetic
tape, the operator then loaded a special program which read the first job from the
tape then ran it. After each job was finished the OS automatically read the next job
from the tape and this continued until the entire batch was done. In this system the
output was put onto a second tape instead of printing it.
The operator removed the input and output tapes and placed a new tape with the
next batch to be completed. There was no integration between the user and the
system during processing and each job has all the resources of the computer at its
disposal when it runs.
E.g.: Payroll and Utility Bills, Credit Cards, all items with monthly statements
Multi-Programming OS
In older systems when the current job is paused waiting for a tape or other IO
operation to complete, the CPU sits idle. To resolve this memory was partitioned into
several pieces with a different job in each partition. This type of OS paved the way
for Time Sharing.
In a Time Sharing OS the CPU can be allocated to the jobs that want a service thus
providing a quick response time.
Multiuser OS
These systems enable many different users to take advantage of the computers
resources simultaneously by isolating users from each other. Each user is able to
use the resource of the computer as if they were completely dedicated to him/her.
-
Overall functions of an OS
1.
2.
3.
4.
5.
Bootstrapping/Bootstrap process
The process of starting up any electronic device (computer, phone etc.). In
computing, boot-strapping is a technique by a simple computer program activates a
more complicated system of programs. During the start-up process of a computer
system, a small program called the BIOS (Basic Input/ Output System), initializes all
aspects of the system (system clock, CPU registers, device controllers, memory
contents etc.). It also tests that hardware, peripherals and external memory devices
are connected. The bootstrap program would then load the OS into memory so that
the rest of the computer can function.
What happens when the pc starts-up?
-
The power supply sends a signal to the components in the system unit.
The processor finds the ROM chip(s) that contains the BIOS.
The BIOS performs POST (Power on Self-test) which components such as
mouse, adaptor cards etc.
The results of the POST are compared with data in CMOS chip.
The BIOS looks for the system files (hard drive/flash drive/optical disc)
The system files and the kernel of the OS are loaded into memory (RAM) from
storage.
The OS load configuration information, may request users info, start several
background processes and display the desktop screen.
Week 2
17/09/14
Computer Science
Process Management
Ready: the process can use the CPU if it was available i.e. it is ready for the
CPU
Running: the process currently has the CPU and the instructions that relate to
that process are being executed.
Blocked: the process is waiting for an event to happen/occur e.g. waiting for
I/O devices
Process transition:
Ready Running (the CPU has become available for the process to use and it
uses it)
Running Ready (the running process has reached the maximum allowable
time for uninterrupted execution i.e. time-out occurs or higher priority process
requires the attention of the CPU)
Running Blocked (the process requested something for which it must wait. i.e.
waiting on input from user, requesting a file, etc.)
Blocked Ready (the external event for which a process was waiting happens. If
no other process is running at that instant, the process will move from ready to
running otherwise it will wait until the CPU is available.)
{Check Exercise Book for Diagram}
Process ID
Process
State
Registers
Memory
Limits
The PCB contains important associated with a specific process, such as:
Process ID: a unique number that identifies each of the running process in an
operating system to help track its information State etc.
Priority of Process
CPU uses this for scheduling; i.e. which process should run and for how long.
Current state of process: the process may be ready, running etc.
Register Information: indicates where data may be stored.
Pointer: A pointer to PCB of the next process to run.
Program counter: address to the next instruction to be executed for the
current process. {Is in all PCB}
The PCB allows the OS to keep track of all processes and differentiate between
them, i.e. what it is, where it is going, how much of its processing has been
completed, where it is stored and how much time it has spent using its
resources.
The OS main objective is to facilitate a multiprogramming environment where
many processes are being executed concurrently. It is the responsibility of the OS
to ensure that each process is given a fair share of the CPUs time, to do this the
OS will employ various methods of scheduling which will ensure the most
efficient use of the CPU. To ensure this occurs the CPU employs a
Week 3
23/09/14
a) A user is running a game on a computer. Indicate what situation would cause the
game process to move from:
i.
Ready to running
The pc becomes available to the game and the game process instructions
begin to run and are executed.
ii.
Running to blocked
Running to blocked would occur when the game is awaiting input from the
user in order to carry out its next instruction, for example, waiting for the
user to select New, Load, or Delete from a game option menu.
24/09/14
Computer Science
Scheduling Algorithms
As each process is given to the CPU, the OS monitor duration of time that the
process uses. Each process is allocated execution time in short bursts called a time
slice or time quantum.
As one process, a, time slice expires, the CPU is given to another process B. When
Bs time slice expires then the CPU is given back to process a or another process
and the cycle continues. The manipulation of the time slice is governed by the
scheduling algorithm being used by the OS.
All computer resources are scheduled before use, each process is represented in
called dispatching.
The major difference between the LTS and the STS is the frequency of
their execution; STS executes more frequently because there are always
jobs on the ready list while the LTS is only put into use when a job is
completed.
Non-preemptive
o The process has full control of the CPU until it completes its execution
or voluntarily moves itself into a different process state i.e. once the
process has the CPU, the CPU cannot be taken away until the process
voluntarily releases it.
Preemptive
o The CPU can be taken away from the process and given to another.
Non-Preemptive
First Come First Serve (FCFS)
-
As processes become ready queue and are arranged in a first in, first out
order. When the current running process finishes execution then the oldest
process (next process in line) then the oldest process in the ready queue is
selected to run.
Proces
s
A
B
C
D
Burs
t
8
4
9
5
B C
D
8
12
21
26
Burs
t
8
4
9
5
D
0
A
4
C
9
17
26
Week 5
10/08/14
Computer Science
Interrupts
An interrupt is a signal generated by an event that alters a sequence in which
a processor executes in structure. When an interrupt occurs the OS saves the state
of the interrupted process, determines what kind of interrupt has occurred and
passes control to the appropriate routine. After the operating system services the
interrupt it will then restart the interrupted process. Interrupts are used to
temporarily suspend a process, so that time critical and other activities can be
performed. They are used by peripheral devices to gain attention of the CPU, the
clock; to effect time sharing and by processes to obtain services provided by the
operating system. NB: hardware triggers an interrupt by sending a signal to
the CPU by way of the system BUS. Whilst, software triggers an interrupt
by executing a special operation referred to as a system call.
Types of Interrupts
1. Interrupt triggered by a running process
The process made need to perform I/O, storage or communicate with the
operator.
2. I/O interrupt
These are initiated by the IO software
Signals to the CPU that status of device or channel has changed
Will occur when IO operation is complete, there is an error or when the
device is made ready.
3. External interrupt
Can be caused by the timer on expiry of a time slice or by pressing a
interrupt key e.g ctrl break.
4. Restart interrupt
Occurs when operator presses the restart button.
5. Program duck interrupt
6. Machine check interrupt
Caused by malfunctioning hardware
NB:
Operating systems are interrupt driven and cannot function without them.
It is desirable to disable some or all interrupts when time critical activities
are to be performed.
Because a computer can be interrupted it can take turns in which
programs or a set of instructions that it can perform. This is known as
multitasking.
When an interrupt occurs that causes the processor to stop executing the sequence
of instructions that it is engaged in, it branches off into an interrupt service routine
or interrupt handler. The interrupt must transfer control to the appropriate interrupt
service routine. The routine in turn will call the interrupt specific handler. The ISR
examines the interrupt and determines how to handle it.
ISRs have a multitude of functions which vary based on the reason the
interrupt was generated and the speed at which the interrupt handler
completes its task.
They must perform very fast to avoid slowing down the operation of the
device and the operation of all lower priority ISRs.
The interrupt handler prioritizes the interrupt and saves them in queue if
more than one is waiting to be handled.
o
o
o
o
o
o
o
o
Class of Interrupt
-