Professional Documents
Culture Documents
Scheduling Using Priorities: New Priority Old Priority Decay-Factor
Scheduling Using Priorities: New Priority Old Priority Decay-Factor
n Question: suppose you have three processes that need to use the
processor in the ratio 3:2:1, how do you setup the priority adjustment?
1
Multiprogramming Linker-loader Approach
n Multiple programs share physical memory n How the linker-loader works?
n when copying a program into memory, use the linker-loader to n Compiler generates .o file with code starting at location 0.
change the addresses for all load/store/jump instructions n Also record all the relocatable addresses
Operating
n Goal: how to support protection?
0xFFFFFF System
virtual physical
address address n Implement protection because there is no way for
Translation Box
CPU
programs to talk about other program’s addresses
(MMU) physical
memory
n How to implement address translation?
n via table lookup (e.g., segmentation, paging …)
Data read or
write
2
Why dual mode operation ? Dual mode operation
n If application can modify its own translation tables --- then n Goal: want to isolate each address space so its behavior
it can access all of physical memory --- protection is lost! can’t do any harm, except to itself
n Solution: use “dual-mode” operation n how to share CPU between kernel and user programs
n when in the OS, can do anything (kernel-mode) n how do programs interact?
n when in a user program, restricted to only touching that program’s
memory (user-mode) n How does one switch between kernel and user modes
(HW can require CPU to be in kernel-mode to modify address translation table) when the CPU gets shared between the OS and a user
program?
n In Nachos (as well as most OS’s):
OS runs in kernel mode (untranslated addresses)
OS à user (kernel mode à user mode)
n
n
n User programs run in user mode (translated addresses)
n User à OS (user mode à kernel mode)
3
Inter-Process Communication Unix: user-kernel interaction
n Inter-address space (inter-process) communication is a n Shell --- user program (not part of the kernel)
kernel service n prompts users to type command
n special system call to copy bytes written by one program to another n does system call to run command
program
n In Nachos, system call to run command is simply “exec”.
But Unix is a bit different
n Models of inter-address space communication:
n Byte stream producer/consumer (Unix pipes connect stdin/stdout) n Unix idea: separate notion of fork and exec
n Message passing (send/receive). Can use this to build remote n fork: create a new process, exact copy of current one
procedure call (RPC) abstraction --- one program calls a procedure n exec: change current process to run different program
in another
n to run a program in Unix
n Shared-memory region. Map part of virtual address space of
n fork a process
different programs to same physical memory
n in child, exec program
n File system (read and write files) is shared state! n in parent, wait for child to finish
n Java defines a portable machine layer --- so any Java programs can store r2, (r1)
run anywhere, dynamically compiled onto native machine
r1:
safeReg <- r1 & segment-mask
Problem: require everyone to learn new language --- any code not in Segment bits
clear segment identifier bits
Java can’t be safely downloaded. safeReg <- safeReg | segment-reg
set segment identifier bits
store r2, (safeReg)