You are on page 1of 10

Week 1

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.
-

Transactions/jobs are processed individually as they arise


Several users from different work stations can run programs simultaneously
Each user assigned time slice
Random access
e.g. library catalog, cash point terminal

Overall functions of an OS
1.
2.
3.
4.
5.

job sequencing (the order in which jobs are processed)


JCL (job command language) handling
Error handling
IO handling
Interrupt handling (any time a resource wants to use the CPU, it issues an
interrupt)
6. Scheduling
7. Resource control
8. Protection

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

NB: a process is a program in execution


The OS must allocate resources to processes, enable processes to share and
exchange information, protect the resources of each process from other
resources and enable synchronization among processes.
Process management is an integral part of any modern day operation. To
meet the requirement above the OS must maintain a data structure for each
process, which describes the state and resource ownership of that process. Thus,
enabling the OS to exert ownership over each, process.
Process States
A process may be in any of the following states:
-

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

{Each process will at least pass through 2 states}

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 Control Block (PCB)


Each process is represented in the operating system by a process control block
(PCB) sometimes referred to as a process table.
Diagram of a PCB

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

process/method known as context switching which allows them to switch


between processes and ensure everyone has a fair share.

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.

b) Outline the function of the process control block (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.
c) Briefly describe four components of the PCB

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.

A good scheduling algorithm should exhibit the following:


1. Fairness- where each process gets a fair share of the CPUs time
2. Efficiency- the CPU should be kept busy at all times.
3. Short Response Time- interactive users should not experience noticeable
delays in the response time.
4. Quick Turnaround Time on Batch Jobs- minimize the time that Batch Users
must wait for output. {NB: Turnaround time is the time interval from the
submission of a job until its completion}
5. Maximize Throughput- focuses on the number of jobs processed per unit time

All computer resources are scheduled before use, each process is represented in

the OS by its own PCB.


There is a long term scheduler (LTS) and a short term scheduler (STS).
o The LTS also known as a job scheduler, determines which jobs are
o

admitted to the system for processing.


The STS also known as a CPU scheduler, selects from the jobs on the
ready list which are ready to execute and assigns the CPU to one of the
jobs. The assignment of the CPU to the job at the front of the ready list is

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.

Types of Scheduling Algorithm


-

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

Using FCFS algorithm, the processes will be executed in this order.


A
0

B C
D
8
12
21

26

Shortest job First


As processes become ready and join the ready queue the process with the shortest
execution will be given the CPU for execution. If there are 2 or more processes in
the queue with the same burst time, then first come first serve scheduling (FCFS) is
used to select the next process to be executed.
Proces
s
A
B
C
D

Burs
t
8
4
9
5

Process will be executed as following:


B

D
0

A
4

C
9

17

26

NB: Shortest job first is good for batch operations.

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.

Interrupt Service Routine (ISR)

Software routine that hardware invokes in response to an interrupt.

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.

What happens when an interrupt occurs?


o
o

o
o
o
o
o
o
o
o

The current fetch execute cycle is completed.


The contents of the program counter which point to the next instruction of
the user program to be executed must be stored away safely so that it can be
restored after servicing the interrupt.
The contents of the other registers used by the user program are stored away
safely for future restoration.
The source of the interrupt is identified.
Interrupts of a lower priority are disabled.
The program counter is loaded with the start address of the relevant ISR.
The ISR is executed and the process which generated the interrupt gets the
attention of the CPU.
The saved values belonging to the user program for registers other than the
program counter are restored.
Interrupts are re-enabled
Program counter is restored to the point of the next instruction to be fetched
and executed in the user program.

Class of Interrupt
-

Hardware failure>Program(division by error)>Arithmetic overflows>


I/O{highest to lowest priority}

You might also like