You are on page 1of 17

Lecture No 4 (b)

Wajid Ullah Khan


Process Deadlocks

Topics to be I/O
Memory
covered Management

File
Memory is central to the
operation of a modern
Memory computer system.

Memory is a large array of words


or bytes, each location with its
own address.

Interaction is achieved through a


sequence of reads/writes of
specific memory address.

The CPU fetches the program


from the hard disk and stores in
the memory.
Memory Manager
Swapping between main
Part of an operating Keeps track of which
memory and disk when
system (OS) that parts of memory are in
not enough memory to
manages memory use
hold all the processes

Allocates/reallocates/de-
allocates memory
to/from processes when
needed
• Memory management is the functionality of an operating
system which handles or manages primary memory and
moves processes back and forth between main memory
and disk during execution.
Memory • Memory management keeps track of each and every
memory location, regardless of either it is allocated to
Management some process or it is free.
• It checks how much memory is to be allocated to
processes. It decides which process will get memory at
what time. It tracks whenever some memory gets freed or
unallocated and correspondingly it updates the status.
Memory Management
❑ Method of managing the primary memory
❑ Goal : Efficient utilization of memory.

Regis
CPU RAM
ter S.M

cache

• Cost
Degree of Multiprogramming
❑ Keep more programs in main memory.
S.M

P1
P2
P3
RAM
P4
Numerical
• Let size we have RAM of size= 4MB
• Process size= 4MB
• Now as result = 1 Process
• Let assume K is the amount of time a process takes in I/O request.
• Accordingly, CPU= 1-k
• E.g K= 70%
• CPU= 1-70%
• Approx= 30%
Numerical 2
• Let size we have RAM of size= 8MB (whenever the size of RAM
increase so CPU utilization?)
• Process size= 4MB
• Now as result = 2 Process
• Let assume K is the amount of time a process takes in I/O request.
• Accordingly, CPU= 1-k2
• E.g K= 70%
• CPU= 1-0.49
• Approx= 50%
Let size we have RAM of size= 16MB

Process size= 4MB

Now as result = ___ Process

Numerical Let assume K is the amount of time a process takes in I/O request.

Accordingly, CPU= _____

E.g K= 70%

CPU= 1-______

Approx= ______
• Swapping is a mechanism in which a process can be
swapped temporarily out of main memory (or move) to
secondary storage (disk) and make that memory available
to other processes. At some later time, the system swaps
back the process from the secondary storage to main
memory.
Swapping • Though performance is usually affected by swapping
process, but it helps in running multiple and big processes
in parallel and that's the reason Swapping is also known as
a technique for memory compaction.
• Let us assume that the user process is of size
2048KB and on a standard hard disk where
swapping will take place has a data transfer
Question rate around 1 MB per second. The actual
transfer of the 1000K process to or from
memory will take.
Memory
Allocation
• Logical Address is generated by CPU while a program is
running. The logical address is virtual address as it does not
exist physically, therefore, it is also known as Virtual Address.
This address is used as a reference to access the physical
memory location by CPU. The term Logical Address Space is
Logical used for the set of all logical addresses generated by a
program’s perspective.
The hardware device called Memory-Management Unit is used
Address Space for mapping logical address to its corresponding physical
address.
& physical • Physical Address identifies a physical location of required data
Address Space in a memory. The user never directly deals with the physical
address but can access by its corresponding logical address.
The user program generates the logical address and thinks that
the program is running in this logical address but the program
needs physical memory for its execution, therefore, the logical
address must be mapped to the physical address by MMU
before they are used. The term Physical Address Space is used
for all physical addresses corresponding to the logical
addresses in a Logical address space.
Differences Between Logical and Physical Address in Operating System

Logical The basic difference between Logical and physical address is that Logical
address is generated by CPU in perspective of a program whereas the
Address physical address is a location that exists in the memory unit.

Space & Logical Address Space is the set of all logical addresses generated by CPU
for a program whereas the set of all physical address mapped to
corresponding logical addresses is called Physical Address Space.
physical
The logical address does not exist physically in the memory whereas
Address physical address is a location in the memory that can be accessed
physically.
Space The logical address is generated by the CPU while the program is running
whereas the physical address is computed by the Memory Management
Unit (MMU).

You might also like