CA_lecture_7
CA_lecture_7
Lecture 7.
. Operating System Support.
Instructors
3
Why Study Operating System?
• Abstraction: gives users the illusion of infinite resources (CPU time, memory, file space)?
• System design: tradeoffs between
–Performance and convenience of these abstractions
–Performance and simplicity of OS
–Functionality in hardware or software
• Primary intersection point: OS is the point where hardware, software, programming
languages, data structures, and algorithms all come together
4
Computer System Structure
5
Four Components of a Computer System
6
Objectives and Functions of OS
• Convenience
– Making the computer easier to use
• Efficiency
– Allowing better use of computer
resources
7
Operating System Services
8
Types of Operating System
9
Simple Batch Systems
10
Job Control Language
❑ Instructions to Monitor
❑ Usually denoted by $
o e.g.
o $JOB
o $FTN
o ... Some Fortran instructions
o $LOAD
o $RUN
o ... Some data
o $END
❑ Memory protection
o To protect the Monitor
❑ Timer
o To prevent a job monopolizing the system
❑ Privileged instructions
o Only executed by Monitor
o e.g. I/O
❑ Interrupts
o Allows for relinquishing and regaining control
12
Multitasking or Time-Sharing Operating
System
❑ Allow users to interact directly with
the computer
o i.e. Interactive
❑ Multi-programming allows a
number of users to interact with the
computer
13
Scheduling Features
14
Scheduling Features
15
Process Scheduling
16
Process Management
Process Control Block
17
Memory Management
• Uni-program
– Memory split into two
– One for Operating System (monitor)
– One for currently executing program
• Multi-program
– “User” part is sub-divided and shared among active processes
18
Swapping
19
Partitioning
20
Relocation
• No guarantee that process will load into the same place in memory
• Instructions contain addresses
– Locations of data
– Addresses for instructions (branching)
• Logical address - relative to beginning of program
• Physical address - actual location in memory (this time)
• Automatic conversion using base address
21
Page Descriptor Base Register
• CR2 is used to store the 32-bit • The lower 12 bits of CR3 are always
linear address of page fault. zero to ensure that the Page Directory
• CR3 (Page Directory Physical Base is always page aligned
Address Register) stores the • A move operation to CR3 automatically
physical starting address of Page loads the Page Table Entry caches and a
Directory. task switch through a TSS changes the
value of CR0.
• MOV CR3,EAX
22
Paging
23
Page Tables
• PTE:-Each Page Table is 4KB and holds up to 1024 Page Table Entries.
• PTEs contain the starting address of the page frame and statistical information about the page.
• Upper 20 bit page frame address is concatenated with the lower 12 bits of the linear address to form
the physical address.
• Page tables can be shared between tasks and swapped to disks.
• P(Present)Bit: indicates if the entry can be used in • D (Dirty) bit: It is set before a write operation to the
address translation. P-bit of the currently executed page is carried out. The D bit is undefined for PDEs.
page is always high. • OS Reserved Bits: They are defined by the operating
• A (Accessed) Bit: It is set before any access to the system software.
page.
• U/S (User/Supervisor)Bit and R/W (Read/Write) Bit:
They are used to provide protection. They are
decoded as
24
Paging Example
25
Paging
26
Segmentation
Advantages of Segmentation
27
Segmentation Hardware
28
Example of Segmentation
29
Segmentation vs. Paging
30
Virtual Memory
• Demand paging
– Do not require all pages of
a process in memory
– Bring in pages as required
• Page fault
– Required page is not in
memory
– Operating System must
swap in required page
– May need to swap out a
page to make space
– Select page to throw out
based on recent history
31
Thrashing
• Solutions
– Good page replacement algorithms
– Reduce number of processes running
– Fit more memory
32
Translation Lookaside Buffer
V D U/S R/W Upper 20 bit Linear Address Upper 20-bit Physical Address
33
TLB Operation
34
TLB and Cache Operation
35
Intel Address Translation Mechanism
36
Intel Paging
37
Intel Segmentation
38
Intel Protection
39
PowerPC Memory Management Hardware
40
PowerPC 32-bit Address Translation
41
Conclusion
42