Where are we?Memory is divided into a set of . partitions (fixed or dynamic), some empty and some...
Transcript of Where are we?Memory is divided into a set of . partitions (fixed or dynamic), some empty and some...
1
Where are we?
2
3
Software CategoriesApplication software
Software written to address specific needs—to solve problems in the real world
System software
Software that manages a computer system at a fundamental level
Can you name examples of each?
4
Roles of an Operating System
Operating system = System software that– manages computer resources, such as
memory and input/output devices– provides an interface through which a human
can interact with the computer– allows an application program to interact
with the other computer resources
5
Roles of an Operating System
Figure 10.1 An operating system interacts with many aspects of a computer system.
What application software have
you used?
What hardware have we encountered in this
class?
What systems software have we encountered
in this class?
6
Roles of an Operating System
The various roles of an OS generally revolve around the idea of “sharing nicely”
An OS manages resources, and these resources are often shared in one way or another among programs that want to use them
7
Batch ProcessingThe first OS was a human operator, who organized the various jobs from multiple users into batches of jobs that needed the same resources.
8
Resource ManagementMultiprogramming
The technique of keeping multiple programs that compete for access to the CPU in main memory at the same time so that they can execute
Memory management
The process of keeping track of what programs are in memory and where in memory they reside
9
Resource ManagementProcess = A program in execution
Process management = The act of carefully tracking the progress of a process and all of its intermediate states
CPU scheduling = Determining which process in memory is executed by the CPU at any given time
10
TimesharingTimesharing system = A system that allows multiple users to interact with a computer at the same time
Virtual machine = The illusion created by a time-sharing system that each user has his/her own machine
As computer speed increased, the human operator became the bottleneck
QUIZ
Compare and contrast multiprgrammingand timesharing!
11
12
10.2 Memory Management (MM)An OS must employ techniques to
– Track where each program resides in memory– Convert logical addresses into actual, physical addresses
Logical addressReference to a stored value relative to the program making the reference
Physical addressActual address in main memory
Why does a computer need logical addresses?
13
AssemblyMachine code
14
Remember from Ch.6
Loader
Program in memory,
a.k.a. process
Execute
15
Remember from Ch.6
Loader
Program in memory,
a.k.a. process
Execute
Problem: There are many programs (multiprogramming), not just one!(The OS itself is one of them!)
Visualizing processes in MS Windows
16
CTRL+SHIFT+ ESC
17
Binding
Figure 10.3 Memory is a continuous set of bits referenced by specific addresses
Program 1:sum is assigned memorylocation 23, a locationrelative to the beginning ofthe process
Logical address for sum (23) is bound to a physical address in memory (20347) beforethe program runs.
18
A. Single Contiguous MM
There are only two programs in memory:
The operating systemThe application program
Figure 10.4 Main memory divided into two sections
19
Single Contiguous MM
Figure 10.5 Binding a logical address to a physical one
If A is address 100, and sum has logicaladdress 23, then sumis stored at physicaladdress 123.
20
Single Contiguous MM recap:
A logical address is simply an integer value relative to the starting point of the program.
A physical address is the logical address plusthe starting location of the program.
QUIZ: Question 48
21
Solution
22
QUIZ: Question 49
23
a. 9223b. 2302c. 7044
Solution
24
QUIZ
25
Assuming that the OS is using single, contiguous MM,
and that the program starts at physical address
0x2D7F000, what is the logical address of the object
above?
26
B. Partitioned MMPartition MM has the OS and any number of other programs in memory simultaneously.There are two schemes for dividing up memory for programs:
– B1. Fixed partitions Main memory is divided into a fixed number of partitions into which programs can be loaded.
– B2. Dynamic partitions Partitions are created as needed to fit the programs waiting to be loaded.
27
Partitioned MMMemory is divided into a set of partitions (fixed or dynamic), some empty and some allocated to programs
Base register = A register that holds the beginning address of the current partition (the one that is running)
Bounds register = A register that holds the length of the current partition
28
Partitioned MM example
Figure 10.6 Address resolution in partition memory management
Why check?
Process 3 is currently being executed
29
Partition Selection AlgorithmsWhich of several empty partitions should the OS allocate to a new program? (B1. Fixed partitions only!)
• First fit Allocate program to the first partition big enough to hold it
• Best fit Allocated program to the smallest partition big enough to hold it
• Worst fit Allocate program to the largest partition big enough to hold it
Why would anyone want to do this?Hint: Think of dynamic partitions
30
QUIZ: Partition Selection Algorithms
31
QUIZ An OS is using the fixed partition shown. Requests come in this order for blocks of sizes: P1:900, P2: 50, P3: 730, P4: 1600, and P5: 325
What block will be assigned to each request if the algorithm used is:
• first-fit?• best-fit algorithm is used?• worst-fit algorithm is used?
32
The Nemesis of all Partition Selection Algorithms: FRAGMENTATION
Source: http://www.technologyuk.net/computing/operating_systems/memory_management.shtml
33
The Nemesis of all Partition Selection Algorithms: FRAGMENTATION
34
Solution: Memory compaction
Source: http://www.technologyuk.net/computing/operating_systems/memory_management.shtml
Problem: When moving the process to a different memory space, all its physical addresses need to be re-bound. This slows down all other processes, b/c the OS needs CPU time to do it!
35
C. Paged MMPaged memory management Processes are divided into fixed-size pages and stored in memory frames when loaded.FrameA fixed-size portion of main memory that holds a process pagePageA fixed-size portion of a process that is stored into a memory frame
We assume that a frame and a page are the same size!
36
The binding mechanism in
Paged MM
Assume that the page size is 1024 Bytes.If P1 is running and it needs logical address 2566,how is the physical address calculated?
37
Integer logical address is mapped into an
intermediate logical address of the form
<page number, offset>
Page numberAddress divided by the page size,1024, Use integer division!
2566 DIV 1024 = 2
OffsetThe remainder of the address divided by the page size
2566 MOD 1024 = 518
Intermediate logical address ==> <2, 518>
Now what?
Paged MM example
38
This intermediate logical address is mapped to a physical address with the help of a page-map table (PMT)
The OS maintains a PMT for every process.
What is the physical address of <2, 518> in P1?
PMT = Paged Map Table
39
What is the physical address of <2, 518> in P1?
PMT = Paged Map Table
P1 PMT: 2 -> 1515x1024 + 518 = 15,878
40
What is the physical address of logical address 3100 in P2?
Quick work for next time
41
What is the physical address of logical address 3100 in P2?
Solution
3100 / 1024 = 33100 % 1024 = 28P2 PMT: 3 -> 1111x1024 + 28 = 11,292
42
Read the remainder of Section 10.2 (pp.351-2) and take notes:
Define these terms:
– Demand paging – Page swap – Virtual memory– Thrashing
43
10.3 Process Management
Process management = Mgmt. of the use of the CPU by individual processesProcess = program in execution
A process goes through multiple stages in order to execute
44
The Process States flowchart
Figure 10.8 The process life cycle
What events can cause a process to move from Running to Waiting state?
• Waiting for user input from KBD• Waiting for a page swap to complete
45
Process Control Block (PCB)
The PCB is data structure used by the OS to manage information about a process, including
– current value of the program counter– values of all CPU registers for the process– base and bound register values (or PMTs)– accounting information
Each state is represented by a list of PCBs, one for each process in that state
46
Context SwitchThere is only one CPU and therefore only one set of CPU registers, which contain the values for the currently executing process.
Each time a process is moved to the Running state:– Register values for the currently running process
are stored into its PCB– Its PCB is moved to the list of the state into which it goes– Register values of the new process moving into the
running state are loaded into the CPU– This exchange of register info. is called a context switch
SKIP 10.4 CPU Scheduling
47
48
Who am I?
I will always beassociated with PCs, a garage and a fruit.
49
Read and take notes: Ethical IssuesMedical Privacy - HIPAA
What is HIPAA?
Explain HIPAA privacy rule(s).
Do you think privacy protection is needed? Why or why not?
Practice/review problems for ch.10:
• 1 through 12
• 27 through 35
• 42, 43, 51, 54, 56, 58, 59, 60, 63, 64, 66
• Extra questions on the following slides …
50
Not a homework, do not turn in!
QUIZ
51
Why do we need logical addresses? Couldn’t
we compile the programs directly with the
physical addresses?
Solution
52
Why do we need logical addresses? Couldn’t we
compile the programs directly with the physical
addresses?
A: No, modern computers run multiple programs
simultaneously (multiprogramming!), so they cannot
all start at address zero in the main memory.
QUIZ:
53
What does contiguous mean in Single, contiguous
memory management?
Solution
54
What does contiguous mean in Single, contiguous
memory management?
A: The one (single) application program is loaded
into one uninterrupted (continguous!) chunk of MM.
QUIZ: Fill in the blanks
55
• Single, contiguous memory management is
used when the MM of the computer contains
___________________________________.
• Partition memory management is used when
the MM of the computer contains ________
___________________________________.
56
Chapter review questions
• Describe the two main responsibilities of an operating system
• Define memory and process management• Explain how timesharing creates the virtual
machine illusion• Explain the relationship between logical and
physical addresses• Compare and contrast the three memory
management techniques presented
57
• Distinguish between fixed and dynamic partitions
• Define and apply partition selection algorithms
• Explain how demand paging creates the virtual memory illusion
• Explain the stages and transitions of the process life cycle
• Explain the operation of the 3 CPU scheduling algorithms presented
Chapter review questions