Вы находитесь на странице: 1из 12

3.3.

1 Operating systems
Operating Systems
I/O
I/O
Manageme
Manageme
nt
nt
Resources
Resources
managem
managem
ent
ent

User
User
inteface
inteface

Operatin
Operatin
g
g
System
System

Error
Error
reporting
reporting

Interrupt
Interrupt
managem
managem
ent
ent

Memory
Memory
managem
managem
ent
ent

Device
Device
managem
managem
ent
ent

Making sure all the parts of the computer can work together.
Making sure that the user can interact with the computer by
providing an interface.
Ensuring that any errors in the computer are reported to the
user, usually with messages on the VDU.
Managing files on the hard drive and in memory and allowing
the user to manage files by providing a file management
utility program.
Making sure that data can be entered into the computer,
displayed or saved by providing software that allows data
input and output.
Providing utility programs such as FORMAT DISK, FILE
MANAGEMENT or DEFRAG.
'Scheduling. The operating system provides programs that
ensure the resources of the computer such as CPU time, are
used as efficiently as possible by all the different users and
the different jobs.

Interrupts
Interrupts are signals generated by a hardware device or by a
software application that tell the CPU it needs some CPU time.
A CPU can only ever do one job at a time, so when the processor
receives a signal, it does one of the following:

The CPU might stop what it is doing and start servicing the
device or software that sent the signal.
The CPU might carry on doing its current job until it is finished
and then service the device or software that sent the signal.
The CPU might carry on doing its current job and then service
other interrupts that have happened.

Different kinds of interrupts


Timer
Restart
interrupt
Interrupts

Program
error
Hardware
error

Occurs at
fixed time
intervals

Violation of
memory
Invalid
instruction
(/0)

I/O

The interrupt process

The CPU has a special register called the interrupt register.


o Two-byte long.
Each bit in the interrupt register will represent a different kind
of interrupt.

1.
2.
3.
4.

Interrupt Register: 0000 0000 0000 0000


Hardware failure so signal is sent to register.
Hardware failure is bit 3 so that bit is set to one.
Interrupt Register: 0000 0000 0000 1000

At the beginning of FDE cycle, each bit in the interrupt register


is checked.
If a bit has been set, it means an interrupt has happened.
The CPU decides whether to services the interrupt
immediately or not by checking priority.
It stops processing the current job, pushing the contents of its
registers onto the stack, which allows the CPU to work freely
and then return to previous task.
It transfers control to the interrupt handling software for that
type of interrupt.

When finished, the contents of the stack are sent back into
appropriate registers.
CPU continues with the task.

Start

Fetch instruction

Yes
Any more instructions?

No
No

Yes

End

Latency issues

Responding quickly enough can be problematic.


A skilled engineer is to write computer code that can deal with
this situation so that every interrupt is handled in time.

Overload

Too many interrupts.


The stack can fill when many interrupts are being stored.
Stack overflow occurs and usually crashes the computer.
Sometime a simple polling system is the way to go for low
demand situations so avoiding tricky interrupts.

Prioritisation of interrupts

Hardware failure: Priority 1 (most important)


Reset interrupt: Priority 2
Program error: Priority 3
Timer: Priority 4
I/O: Priority 5

Scheduling
The objectives of scheduling are to:

maximise the use of the whole of the computer system;


be fair to all users;
provide a reasonable response time to all users, whether they
are on-line users or a batch processing user;
prevent the system failing if it is becoming overloaded;
make sure that the system is consistent by always giving
similar response times to similar activities from day to day.

High-level scheduler

Loads jobs into the ready queue that need processing in order
depending on which algorithm is being utilised.
This queue is called the ready to process queue.

Medium-level scheduler

Responsible for moving a job out of the running state and into
the blocked queue.
o This could be because it requires peripheral usage /
resource of some kind.

What would happen if this job stayed in the running state?


o When the resource becomes available, the job is moved
back into the running state by the MLS.
o If in the blocked state, the MLS can move a job to
secondary storage in order free up primary memory.

Low-level scheduler

Once in the primary memory, the job needs to be selected and


executed.
It checks to see if system resources are available to process
the next job in the ready to process queue.
It then moves the job from the queue into the running state
where it can be processed.
Would there be any reason to move the job out of the running
state?
o The job is finished
o An interrupt is signalled
o System resources become unavailable.

Scheduling Algorithms

FCFS: First come first served


o Simply queues processes in the order that they arrive in
the ready queue.
o No reorganization of the process queue is required,
scheduling overhead is minimal.
o No prioritization occurs, thus the system has trouble
meeting process deadlines.
RR: Round Robin
o The scheduler assigns a fixed time unit per process, and
cycles through them.
o Good average response time, waiting time is dependent
on number of processes, and not average process
length.
o Because of high waiting times, deadlines are rarely met
in a pure RR system.
Shortest Job First
o Scheduler arranges processes with the least estimated
processing time remaining to be next in the queue.
o This requires estimations about the time required for a
process to complete.
o Waiting time and response time increase as the
process's computational requirements increase.
o To use this policy we should have at least two processes
of different priority.
Shortest Remaining Time
o A job is chosen whose remaining run time is the
shortest. For a new job, its run time is compared with
remaining time of current job.
o If new job needs less time to complete than the current
job, then, the current job is blocked and the new job is
run.
o It is used for batch systems and provides advantages to
new jobs.

Any job is in one of three states: ready, running or


blocked
Enter the system

READY

BLOCKED

RUNNING
Leave the system

Job enters the

Memory management
Memory management: deciding how the RAM is to be used for all
of the different applications and data.
RAM (or Immediate Access Store) is used to store data that is
currently in use. When data is opened it is then transferred by the
operating system from a secondary storage device into the IAS.
The loader is responsible for:
Transferring an application or file into an appropriate place in
the primary memory.
Adjusting any references to RAM addresses that have been
made in a program.
When the computer runs out of RAM, it utilises virtual memory:
unused space available on the hard disk.
Therefore, programs can be run when there is not enough memory
because the system relies on the fact that only one application is
serviced at a time and because you dont need the entire code for
an application in RAM at any one moment.

Paging

All programs are split up into equal lengths by the OS (Pages)


The RAM is also split up into pages
The computer keeps as many pages as it can in RAM,
especially those needed to run the active application
The data that cant fit into RAM is stored, in page-size blocks,
in virtual memory in an area called the page file in virtual
memory (overflow area)
When an inactive program needs to be used, the CPU swaps
some pages from the RAM and stores them in the virtual
memory and moves the required pages into RAM.
This takes a little time due to the slower speed of the hard
disk (virtual memory)

Segmentation
Pages are variable in size.
The enables logical grouping of sections of a program.
Previously a frequently used function might span
multiple pages which was inefficient.
Segmentation reduces the size of the paging
table.
Retrieving a segment is more complicated though.
The start address of a segment and its size must
be stored.

Problems
Disk thrashing: processor spends more time swapping
pages than processing tasks, slows down computer.
Affects hard disk performance

Spooling
A print spooler is a piece of software that intercepts details about
files that have been sent to the printer.

It manages the transfer of data between the application and


the printer.
Your application and system resources are then free to
function as normal.
The print spooler can receive lots of jobs at the same time
from lots of different applications.
It is kept track of in a spool queue.
A spool queue also allows for priorities, more important jobs
can push into the queue and be done first.

Print management software


Reasons for their use:
Printing is costly.
It costs a lot of money to buy paper and ink cartridges.
If one person is printing a huge amount of work that is unfair to
people who are waiting, perhaps to print small jobs.
If this keeps happening people will get annoyed!
Print management software can allow organisations to identify
people who are printing huge amounts and to take appropriate
action if necessary.
Limits / fines
Organisations need to budget for resources.
Print management software helps them to do this by
providing information about how much is being printed and
by whom and then controlling it.
Costs can be allocated to printouts so that printing costs can be
charged to projects.
Users with different priorities might need to jump to the front of
the queue.

The head
reads/writes
when above a
track
Set of
magnetic disks

Divided into

Tracks

Tracks

Divided into

Sectors

Sectors are
grouped in

Clusters

Hard Drive

Hard Drive
Computer
automatically
looks for Boot
Files

Which can be edited by the user

Contents of
bootstrap are
loaded into RAM

Bootstrap takes control of loading OS


Locates files and sends them to RAM

Looks for it in storage devices


Looks in boot sector first of the hard drive

BIOS looks for


Bootstrap
program

Runs the POST routine


Checks if there is hardware/storage plugged in
Some is stored in CMOS (allows editing)

BIOS is run

Booting up

File Allocation System (FAT)

Database the keeps a log of every file on the hard drive.


Created by the OS when disk is formatted.
Stored on track zero of the disk itself.
Each file is held in a linked list of clusters.
o The FAT holds the start address of the first cluster in the
linked list
It follows this address and retrieves the first cluster as well as
the address of the next node.
It then follows that address to the next node, recombining the
clusters into a file.
Until the end-of-file marker is reached (null pointer.

Вам также может понравиться