操作系统期末复习
- Consists primarily of:
- Kernel
- Systems programs
-
A program that
- manages computer hardware
- provides basis for application programs
- acts as an bridge between computer user and computer hardware
-
A resources allocator
- manage all resources
- deal with conflict resources request
-
A control program
- control executions of programs to prevent errors and improper use
-
An extended machine
- using abstraction to hide complexity
- provides high level operation using low level operation
-
An virtual machine
- using virtualization to support sharing
- provides virtual CPU, memory, devices
-
A resources manager
- balance overall performance with individual needs
-
make computer system easier to use
- provides interface to run apps
- protect data
- provides read/write interface
- implements TCP/IP stack
-
manage the resources of the computer
- process management
- memory management
- storage management
- protection and security
- another program
- run automatically when you power up your computer
- terminates when you shut down your computer
- Provides lower management of CPU, memory...
- full access to all hardware devices
- only OS Kernel runs here
- limited access to hardware
- all process run in this mode
- a single large program
- all kernel function can be invoked directly
- very difficult to maintain/extend
- difficult to isolate and debug
- each layer provides services to the next higher layers
- layers an change without impacting other layers by not changing the interface
- I/O requires memory management
- Memory management needs I/O
- a bug in OS kernel can kill the system
- kernel contain minimum function
- remaining functionality is moved to "servers"
- easier to port between hardware platforms
- perform is often poor
- OS itself is tiny
- services used by user are provided by "normal" OS running in virtual hardware
- can combine many physical servers into one large server
- computing power can be scheduled to where it is needed dynamically
- Hardware powers up and completes POST(Power On Self Test)
- Microcode in ROM/BIOS performs “bootstrap”
- First-stage boot loader searches devices for second-stage boot loader(PC checks floppy, optical disk, hard disk in some order)
- Second stage boot loader loads and “runs” the OS kernel
- Operating system undertakes initialization then starts one or more standard services to allow the user to interact with the system
he difference is subtle, but absolutely crucial.
a computer scientist wants to bake a birthday cake for his daughter He has a birthday cake recipe and all the input: flour, eggs, sugar, extract of vanilla, and so on.
- The recipe is the program
- the computer scientist is the processor (CPU),and the cake ingredients are the input data.
- The process is the activity consisting of our baker reading the recipe, fetching the ingredients, and baking the cake.
- processes are logical resources
- the concept of process is supported by hardware
- programs
- Datas
- PCB
- all the memory that can be accessed by program code
- switching from one process to another means changing what memory can be accessed
- OS becomes more responsive
- Waste more time
- OS becomes less responsive
- waste less time
- Preempts the currently executing process and save its state
- Change the hardware context to match the next process
- Restore the state of next process and resume its execution
- Once a process is in the running state, it will continue until it terminates or blocks itself for I/O
- Currently running process may be interrupted and moved to the Ready state by the operating system
ready 到 block 是不可能的
- Running
- Ready
- Ready suspend
- Blocked
- blocked supend
- New
- Exit
- Submission of a batch job
- User logs on
- Created to provide a service such as printing
- Process creates another process
- Allocate and initialize a PCB structure
- Allocate at least three memory regions:
- Text
- Data/heap
- Stack region
- Connect standard input/output streams to the process
- Initialize hardware context to match new process
- Switch to user mode
- set program counter to pre-defined code entry point
- Batch job issues Halt instruction
- User logs off
- Quit an application
- Error and fault conditions
- Program invokes a system call to the OS
- OS stores the result in the PCB and frees all memory used by the process
- PCB remains in a ‘terminated’ state until the parent process retrieves the result
- Determines which programs are admitted to the system for processing
- When will the Scheduling be invoked
- Each time a job terminates
- Processor is idle exceeds a certain threshold
- It schedules the process swapped out to disk in memory, ready to execute
- schedule process to run
- execute most frequently
- involved when an event occurs
-
A compute bound process spends most of its time performing computations
-
An I/O bound process spends most of its time waiting for input or output
- Fairness(公平)
- Policy enforcement
- Some jobs may have unusual requirements
- Balance
- Keep as much of the system busy as possible
- Throughput(吞吐量)
- The number of jobs completed per unit of time, e.g., per hour
- Turnaround time(周转时间)
- The time from when a job is first submitted until it is completes/exits
- CPU utilization
- Keep the CPU busy/working at all times, an idle CPU is wasted time
- Remember a context switch is wasted time!
- Response time
- The time it takes for a program to respond to input, e.g., typing in a command to the shell in Linux
- Proportionality(均衡性)
- System matches user expectations, e.g., simple jobs are quick, complex jobs take time
- Meeting deadlines
- Predictability(可预测性)
- Save out memory contents to disk
- Load next program’s memory contents from disk
- Processes have an abstract view of memory (logical address space)
- Every logical memory address is then mapped to a physical address (physical address space)
- processes do not work directly with physical memory Uses hardware support to improve efficiency
first、worst,,,,
- any process whose size is less than or equal to the partition size can be loaded into an available partition.
- if all partitions are full, the operating system can swap a process out of a partition
- Partitions are of variable length and number. Process is allocated exactly as much memory as required.
- Eventually get holes in the memory. This is called external fragmentation(外零头).
- Must use compaction(紧凑) to shift processes so they are contiguous and all free memory is in one block.
略
first号next易混淆
- Processes access virtual address space
- Virtual address space is mapped to the physical address space by:
- Hardware: The MMU(Memory Management Unit) translates virtual memory addresses to physical addresses
- Software: The operating system configures and manages the MMU
- The virtual address space is broken up into small, fixed size chunks known as pages
- Contains page table entries that have been most recently used.
- Functions same way as a memory cache.
- Given a virtual address, processor examines the TLB.
- If page table entry is present (a hit), the frame number is retrieved and the real address is formed.
- If page table entry is not found in the TLB (a miss), the page number is used to index the process page table.
- First checks if page is already in main memory .
- if not in main memory a page fault is issued.
- The TLB is updated to include the new page entry.
银行家算法(强调) 四个条件:mutual exclusion, 没听到1, 没听到2,没听到3
SSF elevator upward & downward