Blue final NEW

Publié par

Research and Training Center on Family Support and Children's Mental Health Families in the World of Evaluation: The Evaluation of the National Federation of Families for Children's Mental Health Course I, “How to Understand Evaluation” May 2003 K at hr yn S ch ut te , M .S .; Pa ul in e Ji va nje e, Ph .D .; A djo a R ob ins on , M .
  • members of evalua- tion teams
  • forts to parents
  • review of relevant literature from the fields of children
  • family support
  • mental health
  • literature review
  • children
  • evaluation
Publié le : mardi 27 mars 2012
Lecture(s) : 33
Source :
Nombre de pages : 13
Voir plus Voir moins

Operating Systems 9/3/2009
What is an Operating System?stem?
• Software that abstracts the computer hardware
– Hides the messy details of the underlying hardware
– Presents users with a resource abstraction that is
easy to use
Computer System Organization
– Extends or virtualizes the underlying machine
• Manages the resources
– Processors, memory, timers, disks, mice, network
CS 256/456
interfaces, printers, displays, …
Dept. of Computer Science
– Allows multiple users and programs to share the
University of Rochester resources and coordinates the sharing, provides
9/3/2009 CSC 2/456 1 9/3/2009 CSC 2/456 2
Operating Systems Concepts Resource Abstraction
load(block, length, device);
seek(device, track);
• Processes
out(device, sector)
• Memory management
write(char *block, int len, int device,
• File systems
int track, int sector) {
• Device management
load(block, length, device);
seek(device, track);
• Security/protection
out(device, sector);
write(char *block, int len, int device,int addr);
fprintf(fileID, “%d”, datum);
9/3/2009 CSC 2/456 3 9/3/2009 CSC 2/456 4
CSC 256/456 - Spring 2007 1Operating Systems 9/3/2009
Disk Abstractions
Under the Abstraction
OS Programmer
• functional complexity
int fprintf(…) {
• a single abstraction over multiple devices
void write() {

•replication → reliability
(c) fprintf()
(a) Direct Control (b) write()
9/3/2009 CSC 2/456 5 9/3/2009 CSC 2/456 6
Resource Sharing
Resourc Sharing
Objectives of Resource Sharing

Program P Program P Program P
i j k
• Efficiency
Extended machine interface (resource abstraction)
Extended machine (re
• Fairness
OS Resource Sharing
P Memory
P Memory

P Memory
Physical Processor
Physical Memory
9/3/2009 CSC 2/456 7 9/3/2009 CSC 2/456 8
CSC 256/456 - Spring 2007 2Operating Systems 9/3/2009
The Device-Controller-Software Relationship
Computer-System Architecture
Device driver
• Software Program to manage device
High-level OS
• System software (part of OS)
Device driver
Device controller Device Controllertroller
• Contains control logic, command
registers, status registers, and on-
board buffer space Device
• Firmware/hardware
9/3/2009 CSC 2/456 9 9/3/2009 CSC 2/456 10
System Protection
I/O Operations
• How is I/O done?
• User programs (programs not belonging to the OS) are generally not
– I/O devices are much slower than CPU trusted
– A user program may use an unfair amount of resource
• Synchronous (polling) – A user program may maliciously cause other programs or the OS to
– After I/O starts, busy-wait while polling the device status register
until it shows the operation completes
• Need protection against untrusted user programs; the system must
differentiate between at least two modes of operations
• Asynchronous (interrupt-driven)
1. User mode – execution of user programs
–, control returns to the user program without
waiting for I/O completion ountrusted
– Device controller later informs CPU that it has finished its o not allowed to have complete/direct access to hardware resources
operation by causing an interrupt
2. Kernel mode (also system mode or monitor mode) – execution of the
– When an interrupt occurs, current execution is put on hold; the CPU
operating system
jumps to a service routine called an “interrupt handler”
o allowed to have complete/direct access to hardware resources
o Hardware support is needed for such protection
9/3/2009 CSC 2/456 11 9/3/2009 CSC 2/456 12
CSC 256/456 - Spring 2007 3
in the machineOperating Systems 9/3/2009
Memory Protection
Transition between User/Kernel Mode
• Goal of memory protection?
• When does the machine run in kernel mode?
– A user program can’t use arbitrary amount of memory
– after machine boot
– A user program can’t access data belonging to the
– interrupt handler
operating system or other user programs
– system call
• How to achieve memory protection?
– exception
– Indirect memory access
• Memory access with a virtual address which needs to be
translated into physical address
– Add two registers that determine the range of legal
Bootstrap addresses a program may access:
Kernel User
• Base register – holds the smallest legal physical memory address
• Limit register – contains the size of the range
• Memory outside the defined range is protected
To user mode
9/3/2009 CSC 2/456 13 9/3/2009 CSC 2/456 14
Hardware Address Protection
Protection of I/O Devices
• User programs are not allowed to directly access I/O
OS kernel
• Address of each
– Special I/O instructions can only be used in kernel
memory address is
program 1 base register mode
checked against
– Controller registers can only be accessed in kernel
300040 “base” and
“base+limit” mode
program 2
• Trap to the OS
kernel if it falls
• So device drivers, I/O interrupt handlers must run in
outside of the
kernel mode
limit register
range (an
program 3
880000 • User programs perform I/O through requesting the OS
program 4 (using system calls)
9/3/2009 CSC 2/456 15 9/3/2009 CSC 2/456 16
CSC 256/456 - Spring 2007 4Operating Systems 9/3/2009
System Call Using the Trap Instruction CPU Protection

read(); • Goal of CPU protection

– A user program can’t hold the CPU for ever
Trap Table
read() {
• Timer – interrupts computer after specified period to ensure

the OS kernel maintains control
trap N_SYS_READ()

– Timer is decremented every clock tick
– When timer reaches the value 0, an interrupt occurs
User program
– CPU time sharing is implemented in the timer interrupt
sys_read() {
/* system function */

9/3/2009 CSC 2/456 17 9/3/2009 CSC 2/456 18
Operation System Organization
Process Management
• System Components • A process is a program in execution
– process management – Unit of work – A process needs certain resources,
including CPU time, memory, files, and I/O devices, to
– memory management
accomplish its task
– I/O system
– Protection domain
– file and storage
– networking, …
• OS responsibilities for process management:
– Process creation and deletion
• Operating System Architectures
– Process scheduling, suspension, and resumption
– monolithic architecture
– Process synchronization, inter-process communication
– microkernel architecture
– layered architecture
– virtual machines
9/3/2009 CSC 2/456 19 9/3/2009 CSC 2/456 20
CSC 256/456 - Spring 2007 5Operating Systems 9/3/2009
Memory Management I/O System Management
• Memory • A computer needs I/O to interact with the outside world:
– A large array of addressable words or bytes. – Console/terminal
– A data repository shared by the CPU and I/O
– Non-volatile secondary storage – disks
– Networking
• OS responsibility for memory management:
• The I/O system consists of:
– Allocate and deallocate memory space as requested
– A buffer-caching system
– Efficient utilization when the memory resource is
– A general device-driver interface
heavily contended
– Drivers for specific hardware devices
– Keep track of which parts of memory are currently
being used and by whom
9/3/2009 CSC 2/456 21 9/3/2009 CSC 2/456 22
File and Secondary Storage
Networking and Communication
• A distributed system
• A file is a collection of information defined by its user.
Commonly, both programs and data are stored as files
– A collection of processors that do not share
• OS responsibility for file management: memory
– Manipulation of files and directories
– Processors are connected through a
– Map files onto (nonvolatile) secondary storage - disks
communication network
• OS responsibility for disk management:
– Communication takes place using a protocol
– Free space management and storage allocation
– OS provides communication end-points or
– Disk scheduling
• They are not all always together
• Inter-process communication (msg, shm, sem)
– Not all files are mapped to secondary storage!
– Not all disk space is used for the file system!
9/3/2009 CSC 2/456 23 9/3/2009 CSC 2/456 24
CSC 256/456 - Spring 2007 6Operating Systems 9/3/2009
OS Architecture: Monolithic
Microkernel System Architecture
• Microkernel architecture:
Interactive User
– Moves as much from the kernel into “user” space (still
protected from normal users).
– Communication takes place between user modules using
Application Application
Libraries Commands
… message passing.
Programs Programs
OS System Call Interface
• What must be in the kernel and what can be in user space?
Trap Table
– Mechanisms determine how to do something.
Device Driverer
– Policies decide what will be done.
Monolithic Kernel Moduleerer
•Process Management
• Benefits:
… •Memory Management
– More reliable (less code is running in kernel mode)
•File Management
•Device Mgmt Infrastructure
Device Driver – More secure (less code is running in kernel mode)er
• Disadvantage?
Most modern OSes fall into this category!
9/3/2009 CSC 2/456 25 9/3/2009 CSC 2/456 26
Layered Structure Virtual Machines
• Virtual machine architecture
• Layered structure
– Virtualization: A piece of software that provides an interface identical
– The operating system is divided into a number of layers (levels),
to the underlying bare hardware.
each built on top of lower layers.
• the upper-layer software has the illusion of running directly on hardware
– The bottom layer (layer 0), is the hardware.
• the virtualization software is called virtual machine monitor
– The highest (layer N) is the user interface.
– Multiplexing: It may provide several virtualized machines on top of a
– Decreased privileges for higher layers.
single piece of hardware.
• Benefits:
• resources of physical computer are shared among the virtual machines
– more reliable
• each VM has the illusion of owning a complete machine
– more secure
• Trust and privilege
– more flexibility, easier to extend
– the VM monitor does not trust VMs
• Disadvantage?
– only the VM monitor runs in full privilege
– Weak integration results in performance penalty (similar to the
microkernel structure).
• Compared to an operating system
– VM monitor is a resource manager, but not an extended machine
9/3/2009 CSC 2/456 27 9/3/2009 CSC 2/456 28
CSC 256/456 - Spring 2007 7
Driver Interf
aceOperating Systems 9/3/2009
Virtual Machine Architecture
System Boot
• How does the hardware know where the kernel
is or how to load that kernel?
user user user user programs
– Use a bootstrap program or loader
programs programs
programs programs
on native
– Execution starts at a predefined memory
location in ROM (read-only memory)
– Read a single block at a fixed location on disk
OS VM monitor
native OS
and execute the code from that boot block
hardware hardware
– Easily change operating system image by
Non-VM Native VM Hosted VM
writing new versions to disk
9/3/2009 CSC 2/456 29 9/3/2009 CSC 2/456 30
System Calls and
User Operating-System Interface
• Examples: Win32, POSIX, or Java APIs
• Command interpreter – special program initiated
when a user first logs on • Process management
– fork, waitpid, execve, exit, kill
• Graphical user interface
• File management
– Common desktop environment (CDE)
– open, close, read, write, lseek
– K desktop environment (KDE)
• Directory and file system management
– GNOME desktop (GNOME)
– mkdir, rmdir, link, unlink, mount, umount
– Aqua (MacOS X)
• Inter-process communication
– sockets, ipc (msg, shm, sem)
9/3/2009 CSC 2/456 31 9/3/2009 CSC 2/456 32
CSC 256/456 - Spring 2007 8Operating Systems 9/3/2009
Process and Its Image User-mode Address Space User
• An operating system executes a variety of programs:
– A program that browses the Web
User-mode address space for a
– A program that serves Web requests
• Text: program code, instructions
• Process – a program in execution.
• Data: initialized global and static
• A process’s state/image in a computer includes: variables (those data whose size is
known before the execution)
– User-mode address space
• BSS (block started by symbol):
– Kernel data structure
uninitialized global and static
– Registers (including program counter and stack pointer)
• Address space and memory protection
• Heap: dynamic memory (those being
malloc-ed) BSS
– Physical memory is divided into user memory and kernel memory
• Stack: local variables and other
– Kernel memory can only be accessed when in the kernel mode
stuff for function invocations
– Each process has its own exclusive address space in the user-
mode memory space (sort-of) Text
9/3/2009 CSC 2/456 33 9/3/2009 CSC 2/456 34
Process Control Block (PCB) Process Creation
• When a process (parent) creates a new process (child)
OS data structure (in kernel
– Execution sequence?
memory) maintaining information
associated with each process.
– Address space sharing?
• Process state
– Open files inheritance?
• Program counter
– ……
• CPU registers
• CPU scheduling information
• UNIX examples
• Memory-management information
– fork system call creates new process with a duplicated
• Accounting information
• Information about open files copy of everything.
• maybe kernel stack?
– exec system call used after a fork to replace the
process’ memory space with a new program.
– child and parent compete for CPU like two normal
9/3/2009 CSC 2/456 35 •9/3/Copy-on-write2009 CSC 2/456 36
CSC 256/456 - Spring 2007 9Operating Systems 9/3/2009
Context Switching Private Address Spaces
• Processes are managed by a shared chunk of OS code
• Each process has its own private address space.
called the kernel
kernel virtual memory
– Important: the kernel is not a separate process, but
(code, data, heap, stack) invisible to
0xc0000000 user code
rather runs as part of some user process
user stack
(created at runtime)
• Control flow passes from one process to another via a
%esp (stack pointer)
context switch.
memory mapped region for
Process A Process B
shared libraries
code code
user code
context switch
kernel code
run-time heap
(managed by malloc)
user code
read/write segment
(.data, .bss)
context switch
kernel code
loaded from the
read-only segment
executable file
(.init, .text, .rodata)
user code
9/3/2009 CSC 2/456 37 9/3/2009 0 CSC 2/456 38
Simple Shell eval Function Func
Problem with Simple Shell Example
void eval(char *cmdline)
char *argv[MAXARGS]; /* argv for execve() */
int bg; /* should the job run in bg or fg? */ • Shell correctly waits for and reaps foreground
pid_t pid; /* process id */
bg = parseline(cmdline, argv);
if (!builtin_command(argv)) {
• But what about background jobs?
if ((pid = Fork()) == 0) { /* child runs user job */
if (execve(argv[0], argv, environ) < 0) {
–Will become zombies when they terminate.
printf("%s: Command not found.\n", argv[0]);
–Will never be reaped because shell (typically)
will not terminate.
if (!bg) { /* parent waits for fg job to terminate */
int status;
–Creates a memory leak that will eventually
if (waitpid(pid, &status, 0) < 0)
unix_error("waitfg: waitpid error"); crash the kernel when it runs out of memory.
else /* otherwise, don’t wait for bg job */
• Solution: Reaping background jobs requires a
printf("%d %s", pid, cmdline);
mechanism called a signal.
9/3/2009 CSC 2/456 39 9/3/2009 CSC 2/456 40
CSC 256/456 - Spring 2007 10

Soyez le premier à déposer un commentaire !

17/1000 caractères maximum.

Diffusez cette publication

Vous aimerez aussi