The document discusses various topics related to memory management in operating systems including swapping, contiguous memory allocation, paging, segmentation, virtual memory concepts like demand paging, page replacement, and thrashing. It provides details on page tables, segmentation hardware, logical to physical address translation, and performance aspects of demand paging. The key aspects covered are memory management techniques to overcome fragmentation and enable efficient use of limited main memory.
a glance on memory management in operating system.
this note is useful for those who are keen to know about how the OS works and a brief explanation regarding several terms such
-paging
segmentation
fragmentation
virtual memory
page table
to A Level A2 Computing students, this light note may be helpful for your revision
a glance on memory management in operating system.
this note is useful for those who are keen to know about how the OS works and a brief explanation regarding several terms such
-paging
segmentation
fragmentation
virtual memory
page table
to A Level A2 Computing students, this light note may be helpful for your revision
The Deadlock Problem
System Model
Deadlock Characterization
Methods for Handling Deadlocks
Deadlock Prevention
Deadlock Avoidance
Deadlock Detection
Recovery from Deadlock
Chorus - Distributed Operating System [ case study ]Akhil Nadh PC
ChorusOS is a microkernel real-time operating system designed as a message-based computational model. ChorusOS started as the Chorus distributed real-time operating system research project at Institut National de Recherche en Informatique et Automatique (INRIA) in France in 1979. During the 1980s, Chorus was one of two earliest microkernels (the other being Mach) and was developed commercially by Chorus Systèmes. Over time, development effort shifted away from distribution aspects to real-time for embedded systems.
Operating System
Topic Memory Management
for Btech/Bsc (C.S)/BCA...
Memory management is the functionality of an operating system which handles or manages primary memory. Memory management keeps track of each and every memory location either it is allocated to 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.
Allocation of processors to processes in Distributed Systems. Strategies or algorithms for processor allocation. Design and Implementation Issues of Strategies.
UNIT II PROCESS MANAGEMENT
Processes-Process Concept, Process Scheduling, Operations on Processes, Interprocess Communication; Threads- Overview, Multicore Programming, Multithreading Models; Windows 7 - Thread and SMP Management. Process Synchronization - Critical Section Problem, Mutex Locks, Semophores, Monitors; CPU Scheduling and Deadlocks.
This Presentation is for Memory Management in Operating System (OS). This Presentation describes the basic need for the Memory Management in our OS and its various Techniques like Swapping, Fragmentation, Paging and Segmentation.
The Deadlock Problem
System Model
Deadlock Characterization
Methods for Handling Deadlocks
Deadlock Prevention
Deadlock Avoidance
Deadlock Detection
Recovery from Deadlock
Chorus - Distributed Operating System [ case study ]Akhil Nadh PC
ChorusOS is a microkernel real-time operating system designed as a message-based computational model. ChorusOS started as the Chorus distributed real-time operating system research project at Institut National de Recherche en Informatique et Automatique (INRIA) in France in 1979. During the 1980s, Chorus was one of two earliest microkernels (the other being Mach) and was developed commercially by Chorus Systèmes. Over time, development effort shifted away from distribution aspects to real-time for embedded systems.
Operating System
Topic Memory Management
for Btech/Bsc (C.S)/BCA...
Memory management is the functionality of an operating system which handles or manages primary memory. Memory management keeps track of each and every memory location either it is allocated to 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.
Allocation of processors to processes in Distributed Systems. Strategies or algorithms for processor allocation. Design and Implementation Issues of Strategies.
UNIT II PROCESS MANAGEMENT
Processes-Process Concept, Process Scheduling, Operations on Processes, Interprocess Communication; Threads- Overview, Multicore Programming, Multithreading Models; Windows 7 - Thread and SMP Management. Process Synchronization - Critical Section Problem, Mutex Locks, Semophores, Monitors; CPU Scheduling and Deadlocks.
This Presentation is for Memory Management in Operating System (OS). This Presentation describes the basic need for the Memory Management in our OS and its various Techniques like Swapping, Fragmentation, Paging and Segmentation.
memory managment on computer science.pptfootydigarse
Description:
This PowerPoint presentation delves into the critical realm of memory management, exploring strategies to optimize system performance and resource utilization. Beginning with an overview of memory management fundamentals, the presentation progresses to examine various memory management techniques employed in modern computing environments. Topics covered include memory allocation algorithms, memory fragmentation mitigation strategies, virtual memory concepts, and the role of caching mechanisms. Through illustrative diagrams, case studies, and real-world examples, the presentation offers insights into best practices for memory management across different computing platforms. Additionally, emerging trends and advancements in memory management technologies are explored, providing attendees with a comprehensive understanding of how to leverage memory management to enhance system efficiency, scalability, and reliability. Whether you're a seasoned IT professional, a software developer, or a student eager to expand your knowledge of memory management, this presentation offers valuable insights into the intricacies of memory optimization in contemporary computing systems.
Palestine last event orientationfvgnh .pptxRaedMohamed3
An EFL lesson about the current events in Palestine. It is intended to be for intermediate students who wish to increase their listening skills through a short lesson in power point.
How to Split Bills in the Odoo 17 POS ModuleCeline George
Bills have a main role in point of sale procedure. It will help to track sales, handling payments and giving receipts to customers. Bill splitting also has an important role in POS. For example, If some friends come together for dinner and if they want to divide the bill then it is possible by POS bill splitting. This slide will show how to split bills in odoo 17 POS.
How to Create Map Views in the Odoo 17 ERPCeline George
The map views are useful for providing a geographical representation of data. They allow users to visualize and analyze the data in a more intuitive manner.
The Indian economy is classified into different sectors to simplify the analysis and understanding of economic activities. For Class 10, it's essential to grasp the sectors of the Indian economy, understand their characteristics, and recognize their importance. This guide will provide detailed notes on the Sectors of the Indian Economy Class 10, using specific long-tail keywords to enhance comprehension.
For more information, visit-www.vavaclasses.com
Unit 8 - Information and Communication Technology (Paper I).pdfThiyagu K
This slides describes the basic concepts of ICT, basics of Email, Emerging Technology and Digital Initiatives in Education. This presentations aligns with the UGC Paper I syllabus.
How to Make a Field invisible in Odoo 17Celine George
It is possible to hide or invisible some fields in odoo. Commonly using “invisible” attribute in the field definition to invisible the fields. This slide will show how to make a field invisible in odoo 17.
Ethnobotany and Ethnopharmacology:
Ethnobotany in herbal drug evaluation,
Impact of Ethnobotany in traditional medicine,
New development in herbals,
Bio-prospecting tools for drug discovery,
Role of Ethnopharmacology in drug evaluation,
Reverse Pharmacology.
2024.06.01 Introducing a competency framework for languag learning materials ...Sandy Millin
http://sandymillin.wordpress.com/iateflwebinar2024
Published classroom materials form the basis of syllabuses, drive teacher professional development, and have a potentially huge influence on learners, teachers and education systems. All teachers also create their own materials, whether a few sentences on a blackboard, a highly-structured fully-realised online course, or anything in between. Despite this, the knowledge and skills needed to create effective language learning materials are rarely part of teacher training, and are mostly learnt by trial and error.
Knowledge and skills frameworks, generally called competency frameworks, for ELT teachers, trainers and managers have existed for a few years now. However, until I created one for my MA dissertation, there wasn’t one drawing together what we need to know and do to be able to effectively produce language learning materials.
This webinar will introduce you to my framework, highlighting the key competencies I identified from my research. It will also show how anybody involved in language teaching (any language, not just English!), teacher training, managing schools or developing language learning materials can benefit from using the framework.
The French Revolution, which began in 1789, was a period of radical social and political upheaval in France. It marked the decline of absolute monarchies, the rise of secular and democratic republics, and the eventual rise of Napoleon Bonaparte. This revolutionary period is crucial in understanding the transition from feudalism to modernity in Europe.
For more information, visit-www.vavaclasses.com
The Roman Empire A Historical Colossus.pdfkaushalkr1407
The Roman Empire, a vast and enduring power, stands as one of history's most remarkable civilizations, leaving an indelible imprint on the world. It emerged from the Roman Republic, transitioning into an imperial powerhouse under the leadership of Augustus Caesar in 27 BCE. This transformation marked the beginning of an era defined by unprecedented territorial expansion, architectural marvels, and profound cultural influence.
The empire's roots lie in the city of Rome, founded, according to legend, by Romulus in 753 BCE. Over centuries, Rome evolved from a small settlement to a formidable republic, characterized by a complex political system with elected officials and checks on power. However, internal strife, class conflicts, and military ambitions paved the way for the end of the Republic. Julius Caesar’s dictatorship and subsequent assassination in 44 BCE created a power vacuum, leading to a civil war. Octavian, later Augustus, emerged victorious, heralding the Roman Empire’s birth.
Under Augustus, the empire experienced the Pax Romana, a 200-year period of relative peace and stability. Augustus reformed the military, established efficient administrative systems, and initiated grand construction projects. The empire's borders expanded, encompassing territories from Britain to Egypt and from Spain to the Euphrates. Roman legions, renowned for their discipline and engineering prowess, secured and maintained these vast territories, building roads, fortifications, and cities that facilitated control and integration.
The Roman Empire’s society was hierarchical, with a rigid class system. At the top were the patricians, wealthy elites who held significant political power. Below them were the plebeians, free citizens with limited political influence, and the vast numbers of slaves who formed the backbone of the economy. The family unit was central, governed by the paterfamilias, the male head who held absolute authority.
Culturally, the Romans were eclectic, absorbing and adapting elements from the civilizations they encountered, particularly the Greeks. Roman art, literature, and philosophy reflected this synthesis, creating a rich cultural tapestry. Latin, the Roman language, became the lingua franca of the Western world, influencing numerous modern languages.
Roman architecture and engineering achievements were monumental. They perfected the arch, vault, and dome, constructing enduring structures like the Colosseum, Pantheon, and aqueducts. These engineering marvels not only showcased Roman ingenuity but also served practical purposes, from public entertainment to water supply.
4. INTRODUCTION:
• Main Memory refers to a physical memory that is the internal
memory to the computer. The word main is used to distinguish it
from external mass storage devices such as disk drives. Main
memory is also known as RAM. The computer is able to change only
data that is in main memory. Therefore, every program we execute
and every file we access must be copied from a storage device into
main memory.
• All the programs are loaded in the main memory for execution.
Sometimes complete program is loaded into the memory, but some
times a certain part or routine of the program is loaded into the main
memory only when it is called by the program, this mechanism is
called Dynamic Loading, this enhance the performance.
• Also, at times one program is dependent on some other program. In
such a case, rather than loading all the dependent programs, CPU
links the dependent programs to the main executing program when
its required. This mechanism is known as Dynamic Linking.
5. Base and Limit Registers
• A pair of base and limit registers define the
logical address space
• CPU must check every memory access
generated in user mode to be sure it is
between base and limit for that user
7. Logical vs. Physical Address Space
• The concept of a logical address space that is bound
to a separate physical address space is central to
proper memory management
– Logical address – generated by the CPU; also referred to
as virtual address
– Physical address – address seen by the memory unit
• Logical and physical addresses are the same in
compile-time and load-time address-binding
schemes; logical (virtual) and physical addresses
differ in execution-time address-binding scheme
• Logical address space is the set of all logical
addresses generated by a program
• Physical address space is the set of all physical
addresses generated by a program
8. Dynamic relocation using a relocation register
Routine is not loaded until it is
called
Better memory-space utilization;
unused routine is never loaded
All routines kept on disk in
relocatable load format
Useful when large amounts of
code are needed to handle
infrequently occurring cases
No special support from the
operating system is required
Implemented through
program design
OS can help by providing
libraries to implement
dynamic loading
9. Swapping
• A process needs to be in memory for execution.
But sometimes there is not enough main memory
to hold all the currently active processes in a
timesharing system. So, excess process are kept
on disk and brought in to run dynamically.
• Swapping is the process of bringing in each
process in main memory, running it for a while
and then putting it back to the disk.
11. Contiguous Memory Allocation
• In contiguous memory allocation each process is
contained in a single contiguous block of
memory. Memory is divided into several fixed
size partitions. Each partition contains exactly
one process. When a partition is free, a process
is selected from the input queue and loaded into
it. The free blocks of memory are known
as holes. The set of holes is searched to
determine which hole is best to allocate.
12. Contiguous Allocation
• Main memory must support both OS and user processes
• Limited resource, must allocate efficiently
• Contiguous allocation is one early method
• Main memory usually into two partitions:
– Resident operating system, usually held in low memory with interrupt
vector
– User processes then held in high memory
– Each process contained in single contiguous section of memory
• Relocation registers used to protect user processes from each
other, and from changing operating-system code and data
– Base register contains value of smallest physical address
– Limit register contains range of logical addresses – each logical
address must be less than the limit register
– MMU maps logical address dynamically
– Can then allow actions such as kernel code being transient and
kernel changing size
14. Memory Protection
• Memory protection is a phenomenon by which
we control memory access rights on a computer.
The main aim of it is to prevent a process from
accessing memory that has not been allocated to
it. Hence prevents a bug within a process from
affecting other processes, or the operating
system itself, and instead results in a
segmentation fault or storage violation exception
being sent to the disturbing process, generally
killing of process.
15. Memory Allocation:
How to satisfy a request of size n from a list of free holes?
Memory allocation is a process by which computer programs
are assigned memory or space.
It is of three types :
• First Fit: The first hole that is big enough is allocated to
program.
• Best Fit: The smallest hole that is big enough is allocated
to program.
• Worst Fit: The largest hole that is big enough is allocated
to program.
First-fit and best-fit better than worst-fit in terms of
speed and storage utilization
16. Fragmentation:
• Fragmentation occurs in a dynamic memory allocation system
when most of the free blocks are too small to satisfy any
request. It is generally termed as inability to use the available
memory.
• In such situation processes are loaded and removed from the
memory. As a result of this, free holes exists to satisfy a request
but is non contiguous i.e. the memory is fragmented into large
no. Of small holes. This phenomenon is known as External
Fragmentation.
• Also, at times the physical memory is broken into fixed size
blocks and memory is allocated in unit of block sizes. The
memory allocated to a space may be slightly larger than the
requested memory. “The difference between allocated and
required memory is known as Internal fragmentation” i.e. the
memory that is internal to a partition but is of no use.
•
17. Fragmentation (Cont.,)
• External Fragmentation – total memory space exists to satisfy a
request, but it is not contiguous
• Internal Fragmentation – allocated memory may be slightly
larger than requested memory; this size difference is memory
internal to a partition, but not being used
• First fit analysis reveals that given N blocks allocated, 0.5 N blocks
lost to fragmentation
1/3 may be unusable -> 50-percent rule
• Reduce external fragmentation by compaction
– Shuffle memory contents to place all free memory together in
one large block
– Compaction is possible only if relocation is dynamic, and is
done at execution time
– I/O problem
• Latch job in memory while it is involved in I/O
• Do I/O only into OS buffers
• Now consider that backing store has same fragmentation problems
18. Paging
A solution to fragmentation problem is Paging. Paging is a
memory management mechanism that allows the physical
address space of a process to be non-contagious. Here
physical memory is divided into blocks of equal size
called Pages. The pages belonging to a certain process are
loaded into available memory frames.
Page Table
• A Page Table is the data structure used by a virtual memory
system in a computer operating system to store the mapping
between virtual address and physical addresses.
• Virtual address is also known as Logical address and is
generated by the CPU. While Physical address is the address
that actually exists on memory.
19.
20. • Every address generated by the CPU is divided
into two parts: Page number (p) and Page offset
(d)
Paging Hardware
21. Paging Hardware
The page number is used as an index into a
Page Table
The page size is defined by the hardware
The size of a page is typically a power of 2,
varying between 512 bytes and 16MB per
page
Reason: If the size of logical address is 2^m
and page size is 2^n, then the high-order
m-n bits of a logical address designate the
page number
23. 23
Page Tables
• The OS now needs to maintain (in main memory) a
page table for each process
• Each entry of a page table consist of the frame
number where the corresponding page is physically
located
• The page table is indexed by the page number to
obtain the frame number
• A free frame list, available for pages, is maintained
27. Implementing PageTable:
• To implement paging, the simplest
method is to implement the page table
as a set of registers
• However, the size of register is limited
and the size of page table is usually
large
• Therefore, the page table is kept in
main memory
28. ADVANTAGES
No external Fragmentation
Simple memory management algorithm
Swapping is easy (Equal sized Pages and Page
Frames)
Share common code especially in a time-sharing
environment
DISADVANTAGES
Internal fragmentation
Page tables may consume more memory.
Multi level paging leads to memory
reference overhead.
29. Segmentation
Segmentation is another memory management scheme that supports the
user-view of memory. Segmentation allows breaking of the virtual
address space of a single process into segments that may be placed in
non-contiguous areas of physical memory.
Segmentation with Paging
Both paging and segmentation have their advantages and
disadvantages, it is better to combine these two schemes to improve
on each. The combined scheme is known as 'Page the Elements'. Each
segment in this scheme is divided into pages and each segment is
maintained in a page table.
So the logical address is divided into following 3 parts :
• Segment numbers(S)
• Page number (P)
• The displacement or offset number (D)
30. Logical addressing in Segmentation
Logical Address space
Segment number
Offset
The mapping of the logical address to the physical address is done
with the help of the segment table.
Segment Limit Segment Base Other bits
A bit is needed to determine if the segment is
already in main memory (P)
Another bit is needed to determine if the segment
has been modified since it was loaded in main
memory (M)
the length of the
segment SEGMENT TABLE
starting address of the
corresponding segment in
main memory
33. ADVANTAGES OF SEGMENTATION
• No internal fragmentation
• Segment tables consume less memory than page
tables ( only one entry per actual segment as opposed
to one entry per page in Paging method)
• Because of the small segment table, memory
reference is easy.
• Lends itself to sharing data among processes.
• Lends itself to protection.
• As the individual lines of a page do not form one
logical unit, it is not possible to set a particular
access right to a page.
• Note that each segment could be set up an access
right
34. DISADVANTAGES
• External fragmentation.
• Costly memory management algorithm
• Unequal size of segments is not good in the case of swapping.
So, why can’t we combine the ease of sharing and
protection we get from segments with efficient
memory utilization we get from pages ????
35. Paging verses Segmentation
Paging Segmentation
Each process is assigned its
page table.
Page table size proportional
to allocated memory
Often large page tables
and/or multi-level paging
Internal fragmentation
Free memory is quickly
allocated to a process
Each process is assigned a
segment table
Segment table size
proportional to number of
segments
Usually small segment tables
External fragmentation.
Lengthy search times when
allocating memory to a
process.
37. What is Virtual Memory?
Virtual Memory is a space where large programs can store
themselves in the form of pages while their execution and
only the required pages or portions of processes are loaded
into the main memory. This technique is useful as large
virtual memory is provided for user programs when a very
small physical memory is there.
In real scenarios, most processes never need all their pages at
once, for following reasons :
• Error handling code is not needed unless that specific
error occurs, some of which are quite rare.
• Arrays are often over-sized for worst-case scenarios, and
only a small fraction of the arrays are actually used in
practice.
• Certain features of certain programs are rarely used.
38. Benefits of having Virtual Memory
• Large programs can be written, as virtual space
available is huge compared to physical
memory.
• Less I/O required, leads to faster and easy
swapping of processes.
• More physical memory available, as programs
are stored on virtual memory, so they occupy
very less space on actual physical memory.
39. What is Demand Paging?
• The basic idea behind demand paging is that when a process is swapped
in, its pages are not swapped in all at once. Rather they are swapped in
only when the process needs them(On demand). This is termed as lazy
swapper, although a pager is a more accurate term.
• Initially only those pages are loaded which will be required the process
immediately.
40. The pages that are not moved into the memory, are marked as invalid in the page table.
For an invalid entry the rest of the table is empty. In case of pages that are loaded in
the memory, they are marked as valid along with the information about where to
find the swapped out page.
When the process requires any of the page that is not loaded into the memory, a page
fault trap is triggered and following steps are followed:
1. The memory address which is requested by the process is first checked, to verify
the request made by the process.
2. If its found to be invalid, the process is terminated.
3. In case the request by the process is valid, a free frame is located, possibly from a
free-frame list, where the required page will be moved.
4. A new operation is scheduled to move the necessary page from disk to the
specified memory location. ( This will usually block the process on an I/O wait,
allowing some other process to use the CPU in the meantime. )
5. When the I/O operation is complete, the process's page table is updated with the
new frame number, and the invalid bit is changed to valid.
6. The instruction that caused the page fault must now be restarted from the
beginning.
There are cases when no pages are loaded into the memory initially, pages are only
loaded when demanded by the process by generating page faults. This is called Pure
Demand Paging.
The only major issue with Demand Paging is, after a new page is loaded, the process
starts execution from the beginning. Its is not a big issue for small programs, but for
larger programs it affects performance drastically.
41. PURE DEMAND PAGING
We start executing a process with no pages in the memory.
When the Operating System sets the instruction pointer to
the first pointer instruction of the process, which is on a non
memory resident page, the process immediately faults for the
process. After this page is brought into the memory, the
process continues to execute, faulting as necessary until every
page that it needs is in memory.
At this point, it can execute with no more faults. This is Pure
Demand Paging.
42. HARDWARE SUPPORT
The hardware to support demand paging is the same as the
hardware for paging and swapping:
PAGE TABLE : This table has the ability to mark an entry
invalid through a valid invalid bit or a special value of
protection bits.
SECONDARY MEMORY : The memory holds those pages
that are not present in the main memory. The secondary
memory is usually a high speed disk.
It is known as Swap Device and the section of the disk used
for this purpose is known as the Swap Space.
43. Performance of Demand Paging
• Page Fault Rate 0 < p < 1.0
- if p = 0 no page faults
- if p = 1, every reference is a fault
• Effective Access Time (EAT)
EAT = (1 - p) x memory access
+ p (page fault overhead
+ swap page out
+ swap page in
+ restart overhead)
44. Demand Paging Example
• Memory access time = 200 nanoseconds
• Average page-fault service time = 8 milliseconds
• EAT = (1 - p) x 200 + p (8 milliseconds)
= (1 - p x 200 + p x 8,000,000
= 200 + p x 7,999,800
EAT is directly proportional to the page fault rate.
45. What happens if there is no free frame?
• Page replacement - find some page in memory,
but not really in use, swap it out
- Algorithm
- Performance - want an algorithm which will result in
minimum number of page faults
• Same page may be brought into memory several
times
46. Page Replacement
• As studied in Demand Paging, only certain pages of a process
are loaded initially into the memory. This allows us to get more
number of processes into the memory at the same time. but
what happens when a process requests for more pages and no
free memory is available to bring them in.
• Following steps can be taken to deal with this problem :
1. Put the process in the wait queue, until any other process
finishes its execution thereby freeing frames.
2. Or, remove some other process completely from the
memory to free frames.
3. Or, find some pages that are not being used right now,
move them to the disk to get free frames. This technique is
called Page replacement and is most commonly used. We
have some great algorithms to carry on page replacement
efficiently.
47. Basic Page Replacement
• Find the location of the page requested by ongoing process on
the disk.
• Find a free frame. If there is a free frame, use it. If there is no
free frame, use a page-replacement algorithm to select any
existing frame to be replaced, such frame is known as victim
frame.
• Write the victim frame to disk. Change all related page tables to
indicate that this page is no longer in memory.
• Move the required page and store it in the frame. Adjust all
related page and frame tables to indicate the change.
• Restart the process that was waiting for this page.
48. STEPS IN PAGE REPLACEMENT :
Find the location of the desired page on the disk.
Find a free frame :
If there is a free frame, use it.
If there is no free frame, use a page replacement algorithm
to select a victim frame.
Write the victim frame to the disk, change the page and
frame tables accordingly.
Read the desired page into the newly freed frame, change
the page and frame tables.
Restart the user process.
49. Page Replacement
Use modify (dirty) bit to reduce overhead of page transfers -
only modified pages are written to disk
50. Page Replacement Algorithms
• Want lowest page-fault rate
• Evaluate algorithm by running it on a particular
string of memory references (reference string)
and computing the number of page faults on
that string
• In all our examples, the reference string is
7,0,1,2,0,3,0,4,2,3,0,3,2,1,2,0,1,7,0,1
51. FIFO Page Replacement
• A very simple way of Page replacement is FIFO (First in
First Out)
• As new pages are requested and are swapped in, they are
added to tail of a queue and the page which is at the
head becomes the victim.
• Its not an effective way of page replacement but can be
used for small systems.
54. Optimal Page Replacement
Replace page that will not be used for longest period of time
Unfortunately, the optimal page-replacement is difficult to implement,
because it requires future knowledge of the reference string
55. Least Recently Used (LRU) Algorithm
• LRU replacement associates with each page
the time of that page’s last use
• When a page must be replaced, LRU chooses
the page that has not been used for the
longest period of time
57. LRU Implementation
• The major problem is how to implement LRU
replacement:
- Counter: whenever a reference to a page is made,
the content of the clock register are copied to the
time-of-use field in the page table entry for the
page. We replace the page with the smallest time
value
- Stack: Whenever a page is referenced, it is
removed from the stack and put on the top. In this
way, the most recently used page is always at the
top of the stack
59. Allocation of Frames
• Each process needs minimum number of pages
• Two major allocation schemes :-
- fixed allocation
- priority allocation
• The minimum no. of frames per process is
defined by the architecture, the maximum no.
is defined by the amount of physical memory.
60. Fixed Allocation
• Equal allocation - For example, if there are 100 frames
and 5 processes, give each process 20 frames.
• Proportional allocation - Allocate according to the size
of process
m= 64
s i size of process p is1 =10
S
s =1272
a1
= (10/137) * 64 = 4
m is total number of free frames
a
a i allocation for pi ( si / S )* m
2 = (127/137) * 64 = 57
is sum of all the process
61. Priority Allocation
• Use a proportional allocation scheme using
priorities rather than size
• If process Pi generates a page fault,
- select for replacement one of its frames
- select for replacement a frame from a process with
lower priority number
62. Global vs. Local Allocation
• Global replacement - process selects a
replacement frame from the set of all frames;
one process can take a frame from another
• Local replacement - each process selects from
only its own set of allocated frames
63. Thrashing
• A process that is spending more time paging than executing is said to be
thrashing. In other words it means, that the process doesn't have enough
frames to hold all the pages for its execution, so it is swapping pages in and
out very frequently to keep executing. Sometimes, the pages which will be
required in the near future have to be swapped out.
• Initially when the CPU utilization is low, the process scheduling
mechanism, to increase the level of multiprogramming loads multiple
processes into the memory at the same time, allocating a limited amount of
frames to each process. As the memory fills up, process starts to spend a lot
of time for the required pages to be swapped in, again leading to low CPU
utilization because most of the processes are waiting for pages. Hence the
scheduler loads more processes to increase CPU utilization, as this continues
at a point of time the complete system comes to a stop.
64. To prevent thrashing we must provide processes with as many frames as they really
need "right now".
65. FILE SYSTEM
• File concept
• Access methods
• Directory structure
• File System Mounting
• File sharing
• Protection
• File system structure and implementation,
• Directory implementation
• Allocation methods
• Free space management
• Efficiency and performance, Recovery
66. Introduction to File System
A file can be "free formed", indexed or structured collection of
related bytes having meaning only to the one who created it.
Or in other words an entry in a directory is the file. The file
may have attributes like name, creator, date, type,
permissions etc.
File Structure:
A file has various kinds of structure. Some of them can be :
• Simple Record Structure with lines of fixed or variable
lengths.
• Complex Structures like formatted document or
reloadable load files.
• No Definite Structure like sequence of words and bytes
etc.
67. Attributes of a File
Following are some of the attributes of a file :
• Name . It is the only information which is in human-
readable form.
• Identifier. The file is identified by a unique tag(number)
within file system.
• Type. It is needed for systems that support different types
of files.
• Location. Pointer to file location on device.
• Size. The current size of the file.
• Protection. This controls and assigns the power of reading,
writing, executing.
• Time, date, and user identification. This is the data for
protection, security, and usage monitoring.
68. File Access Methods
The way that files are accessed and read into memory is determined by
Access methods. Usually a single access method is supported by
systems while there are OS's that support multiple access methods.
1. Sequential Access
• Data is accessed one record right after another is an order.
• Read command cause a pointer to be moved ahead by one.
• Write command allocate space for the record and move the pointer to
the new End Of File.
• Such a method is reasonable for tape.
2. Direct Access
• This method is useful for disks.
• The file is viewed as a numbered sequence of blocks or records.
• There are no restrictions on which blocks are read/written, it can be
dobe in any order.
• User now says "read n" rather than "read next".
• "n" is a number relative to the beginning of file, not relative to an
absolute physical disk location.
3. Indexed Sequential Access
• It is built on top of Sequential access.
• It uses an Index to control the pointer while accessing files.
69. What is a Directory?
Information about files is maintained by Directories. A directory can contain
multiple files. It can even have directories inside of them. In Windows we
also call these directories as folders.
Following is the information maintained in a directory :
• Name : The name visible to user.
• Type : Type of the directory.
• Location : Device and location on the device where the file header is
located.
• Size : Number of bytes/words/blocks in the file.
• Position : Current next-read/next-write pointers.
• Protection : Access control on read/write/execute/delete.
• Usage : Time of creation, access, modification etc.
• Mounting : When the root of one file system is "grafted" into the existing
tree of another file system its called Mounting.