FIT1047 Study Guide - Final Guide: Context Switch, Subroutine, Interrupt Handler

118 views6 pages
Virtualising the CPU
Saturday, 26 May 2018
8:35 PM
Goal of Virtualising the CPU is to run multiple processes simultaneously, but in a way that
individual processes don't know that they are running in parallel with other processes.
The Operating System creates this illusion of many processes running in parallel by switching
between the processes several times per second
o A process shouldn't notice that it's not running continuously.
o Each process would get a fair share of the overall CPU time
Virtualisation mechanisms
Mechanisms for virtualising a CPU:
o Ready
o Running
o Blocked
When the process is created by loading program code into memory, it is put into the ready
state
o Ready means ready for execution, but not currently being executed by the CPU
When the OS decides that the process should now be executed, it puts it into running state.
(OS schedules the process)
o In the running state, the code for the process is actually executed on the CPU
2 things can happen after:
o Either the OS decides that the time for this process is up
Process is de-scheduled, and put back into ready state, from which it will be
scheduled again in the future
o Or the process requests some I/O to happen
Opening a file from an external storage
I/O can take a long time, so the process will have to wait until the file has been
opened. The OS takes advantage of this opportunity and puts the process into the
blocked state
As soon as the I/O is finished, the process will be put back into ready, from which
it will be scheduled again
find more resources at oneclass.com
find more resources at oneclass.com
Unlock document

This preview shows pages 1-2 of the document.
Unlock all 6 pages and 3 million more documents.

Already have an account? Log in
Limited Directed Execution
CPU Virtualisation via process switching has a number of challenges:
Performance
o Virtualisation should not create a huge overhead, and most of the CPU time should be
spent on actually running processes, not managing them
Control
o The OS should enable fair scheduling of processes and offer a certain level of protection
against malicious or buggy code
The solution to these challenges is to get some support from the hardware in a mechanism called
limited directed execution (LDE).
In order to achieve good performance, each process is allowed to run directly on the CPU
This is what direct means in LDE.
CPUs have different modes of operations that enables the OS to restrict what an application
program can do
User Mode
Only a subset of all instructions are allowed to be executed
Instructions that perform I/O is not allowed in user mode
Normal applications are executed in user mode
Kernel Mode
Code is run without any restrictions
Has full access to I/O devices and memory
OS runs in Kernel mode
Whenever an interrupt happens, the CPU switches into kernel mode to execute the interrupt
handler
Sometimes called supervisor mode
Notes:
User modes places quite severe restrictions on application programs
o Without access to I/O instructions, a program cannot read any files, send or receive
messages over networks, or draw characters on the screen
o Applications need to do all these things
In order to give user mode processes access to these "privileged" operations, the OS provides
a number of "hooks" that a user mode process can use
o Much like subroutines, to perform functions like reading from a disk or sending a
message over the network
o These hooks are called system calls
System Calls
A system call is a special CPU instruction that switches the CPU from user mode into kernel mode,
then jumps to a special subroutine of the OS
Many CPU architectures simple provide an instruction that causes in interrupt, which causes
the switch to kernel mode
find more resources at oneclass.com
find more resources at oneclass.com
Unlock document

This preview shows pages 1-2 of the document.
Unlock all 6 pages and 3 million more documents.

Already have an account? Log in

Document Summary

I/o can take a long time, so the process will have to wait until the file has been opened. The os takes advantage of this opportunity and puts the process into the blocked state: as soon as the i/o is finished, the process will be put back into ready, from which it will be scheduled again. The solution to these challenges is to get some support from the hardware in a mechanism called limited directed execution (lde). In order to achieve good performance, each process is allowed to run directly on the cpu. Cpus have different modes of operations that enables the os to restrict what an application program can do. User mode: only a subset of all instructions are allowed to be executed, normal applications are executed in user mode. Instructions that perform i/o is not allowed in user mode.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers

Related Documents