3. Sys Nucleus-1

Embed Size (px)

Citation preview

  • 8/2/2019 3. Sys Nucleus-1

    1/20

    School of Computing and

    Technology

    SYSTEMS SOFTWARE

  • 8/2/2019 3. Sys Nucleus-1

    2/20

    SECTION 4 : THE SYSTEM NUCLEUS- Operating System structure resembles an onion: eachlayer provides functions to layers above it using facilities

    provided by layers within it.- Successive Virtual Machines; user machine is the wholeonion.- System Nucleus: is the interface between the operatingsystem & the HW; it is the innermost layer. It isresponsible for :

    * Handling all interrupts;* Switching processor between processes;* Implementing Signal & Wait operations, i.e.

    provide the mechanisms for inter-process comms.

    OPERATING SYSTEMS

  • 8/2/2019 3. Sys Nucleus-1

    3/20

    1.1 Interrupt mechanism:- Why do we need an interrupt mechanism?

    when I/O is overlapped with processing, the current runningprocess need to be interrupted when I/O transfer is complete.- When interrupt occurs, the program counter (PC) of the

    interrupted process is saved & control is transferred to apredetermined memory location which is the start of theinterrupt-routine or -handler.- The interrupt routine determines the source of interrupt &responds as necessary.- Some computers have no interrupt mechanism butperipheralprocessors instead.

    1. WHAT HW FACILITIES DOES THENUCLEUS NEED TO DO ITS JOB?

  • 8/2/2019 3. Sys Nucleus-1

    4/20

    1.3 privileged instruction set: part of the instruction

    set is reserved for the operating system only, andinclude:

    I. Enabling and disabling interrupts;

    Ii. Switching a processor between processes;Iii. Accessing registers used by the memory

    protection H/W;Iv. I/O operations;V. Halt instruction.Privileged instruction set is itself enabled/disabled

    by switching the cpu between:I. Supervisor mode (privileged instn set on);Ii. User mode (privileged instn set off).

    1.2 memory protection: a mechanism isneeded to protect one process from theunauthorised access by another.

  • 8/2/2019 3. Sys Nucleus-1

    5/20

    Automatic switching from user to supervisor mode occurs if:i. a user process calls op sys to do a special function that needs

    privileged instructions, i.e. supervisorcall or extracode;ii. an interrupt occurs (external);iii. an internal interrupt occurs (e.g. after executing a Trap instn

    (PDP11)) usually after an error condition In a user process;iv. a user process tries to execute a privileged instn (naughty)

    which causes an internal interrupt as in iii above.Switching from supervisor to user modes is by a privileged

    instruction.Some architecture extends the privileged idea to several levels,

    e.g. ICL2900.

    1.4 A Real Time Clock: to interrupt at regular intervals need for:i. Scheduling of processes and users;ii. Accounting.

  • 8/2/2019 3. Sys Nucleus-1

    6/20

    2. OUTLINE OF THE NUCLEUS

    user

    otherlayers

    nucleus

    privileged hardware

    instruction set(nucleus only can use)

  • 8/2/2019 3. Sys Nucleus-1

    7/20

    Nucleus consists of:

    i. First Level Interrupt Handler;ii. Dispatcher: switches processor between processes;iii. Signal and Wait procedures.Nucleus is:i. the most heavily machine-dependent part of the opsys.ii. probably the only part written in assembly language.Major advance in op sys design: the separation of the

    system nucleus from other layers.

  • 8/2/2019 3. Sys Nucleus-1

    8/20

    ii. reduces errors (all other layers are written in high level languages);ii. comprehensible;iii. maintainable;iv. time saving in I, ii, iii.

    Advantages in implementing op sys design:

    3. PROCESS REPRESENTATION:Need a data structure to physically represent processes within the system.Process Descriptor (or Control Block or State Vector): consists of a memory area thathold all info on the process.

  • 8/2/2019 3. Sys Nucleus-1

    9/20

    Name Tim

    Status runnable 4. running(currentprocess)

    5. runnable

    6. unrunnableOther info e.g.

    initializationconstants

    Volatileenvironment

    Other namesused:

    Process Statusor ContextBlock

    ProgCounter

    ProcessorStatus

    info saved whenprocess loses

    control ofprocessor, i.e.becomes eitherrunnable orunrunnable

    Processor Descriptor I

  • 8/2/2019 3. Sys Nucleus-1

    10/20

    - Number of processes which are current number of processors available.- Volatile Environment: is the subset of Modifiable Shared Facilities accessibleto the process.Process Structure: a description of all processes int he system.- the most basic form of a Process Structure is a linked list.- There are many other data structures in the op sys. The table that containall these structures is the CENTRAL TABLE.

  • 8/2/2019 3. Sys Nucleus-1

    11/20

  • 8/2/2019 3. Sys Nucleus-1

    12/20

    4. FIRST LEVEL INTERRUPT HANDLER(FLIH) : responsible for responding tointerrupts (external from outsideworld, and internl : traps caused by

    errors and extracode).

    FUNCTION OF FLIH

    i. Determine source of interrupts;

    ii. Service the interrupt

  • 8/2/2019 3. Sys Nucleus-1

    13/20

    6-10

    i. DETERMINING INTERRUPT

    SOURCE PROCESS

    INTERRUPT . FLIH? Source ?

    a. Single Interrupt Location Machine

    - Interrupt Mechm saves PC.

    - Regs used by interrupted

    process and required by FLIH :must be saved by FLIH andreinstated.

    - No. of Regs thussaved/reinstated is small,

  • 8/2/2019 3. Sys Nucleus-1

    14/20

    - Determine interrupt sourceusing a skip chain:

    May be doneby H/W

    Save ProgRegs

    IntrptSrce1?

    Y? Service Rtn forSrce 1 (mostfrequent)

    N

    Skip Chain IntrptSrce 2

    Y?Service Rtn forSrce 2

    N

    IntrptSrce N? Y?

    Service Rtn forSrce N (leastfrequent)

    ? NError Rtn

    forUnknown

  • 8/2/2019 3. Sys Nucleus-1

    15/20

    b. Multiple Interrupt Location Machines:

    - Interrupt Source identified by H/W,-transfers control to separate location

    for each source.

    - Much faster, but more expensive.

    c. Compromise:

    - Several interrupt locations, eachservicing a group of devices,

    - 2 level Source identification:

    i. H/W to identify the groupii. S/W skip to identify device within

    group

    - Further info about interrupt may be

    saved by H/W in a pre-determinedmemory location.

    d. Multi-level Interrupts:

    - In single level interrupt machines FLIH insupervisor mode cannot be interrupted;interrupt is held pending until return

    from FLIH.

  • 8/2/2019 3. Sys Nucleus-1

    16/20

    - This is not acceptable, somedevices need fast response or datais lost - >

    - need facility to interrupt

    interrupts.

    - an interrupt must have higherpriority than a currently servicedinterrupt in order to interrupt it.

    - Multi-level interrupts: if done inS/W then FLIH disables all other

    interrupts of = or < priority.

    Careful: store Regs of interruptedprocess in different locations toguarantee integrity of RTIs (ReTurnfrom Interrupt).

    - OR, H/W distinguishes betweenpriority levels and transfers control

    and store registers appropriately foreach level. H/W inhibits interruptsat lower or same level.

    Classical examples: DEC10 7 levelsPDP11 4 levels

  • 8/2/2019 3. Sys Nucleus-1

    17/20

    ii. SERVICING INTERRUPTS

    - Interrupt Routines run in

    supervisory mode: other interrupts

    are partially or completely inhibited.

    Must keep Interrupt Routines as

    short as possible.

    - Typically FLIH routines do very

    little, e.g. transfer character

    between buffer and I/O device.

    - More detailed handling of what to

    do with these chars (eg. input) isdone by a process in user mode.

    - Interrupts Change Process Status

    - A process which is un-run-able, is

    usually waiting for I/O transfer to

    complete.

    - Interrupt occurs when I/O transfer

    is done : this makes process run-able.

  • 8/2/2019 3. Sys Nucleus-1

    18/20

    - Wait operation on zero semaphoremakes process un-run-able (internalinterrupt).

    - Result of interrupt routines: changeprocess status in the process descriptor.

    - Which process to run next must becontrolled systematically: this is the job of

    the DISPATCHER.

  • 8/2/2019 3. Sys Nucleus-1

    19/20

    QUESTIONSLECTURE: The System Nucleus

    1. Explain the term System Nucleus and list its functions.

    2. What processor facilities does the nucleus need in order

    to perform its functions? Discuss the interrupt handlingmechanism.

    3. What is a privileged instruction set? Name someinstructions considered to be privileged and explain the

    terms supervisor mode and user mode.

    4. Discuss the instances when switching from user tosupervisor modes occurs automatically. How does

    switching from supervisor to user mode happen?

    5. Explain why the nucleus needs a real time clock.

    6. List the 3 constituent parts of the nucleus and discuss

    the advantages of separating them from otheroperating systems elements.

    7. What is a process descriptor? Using diagrams explain

    the elements of a process descriptor and discuss thefunction of the central table.

    8. What is a First Level Interrupt Handler? Discuss its

    functions with particular reference to single interruptlocation machines mentioning skip changes in youranswer.

    9. Explain how multi-level interrupts are handled in:

    a. software, andb. hardware

    10.Discuss why and how process status is changed by interrupts.

  • 8/2/2019 3. Sys Nucleus-1

    20/20