SlideShare uma empresa Scribd logo
1 de 35
UNIX MEMORY
MANAGEMENT




              1
AGENDA
 Introduction
 History of UNIX
 Swapping
 Demand Paging
Page Replacement Algorithm
 Kernel Memory Allocator
 Conclusion

                              2
Introduction

 UNIX is a portable, multi-tasking and multi-user operating
  system.
   – Portable: runs on many different hardware architectures (Intel
     x86 and IA-64, Alpha, MIPS, HP PA-RISC, PowerPC, IBM
     S/390, SPARC, Motorola 680x0, etc.).
   – Preemptive multi-tasking: several programs can run at the
     same time (time slices, interrupts, and task switching).
   – Multi-user: many users can share the computer system at the
     same time.


                                                                  3
Other Features…

• Uses a simple, uniform file model which includes devices and
  access to other services in a flexible, hierarchical file system.
• Written in a high-level language (“C”) making it easy to
  read, understand, change and port.
• The command prompt is a simple user process, the Unix shell,
  which is also a convenient job programming language.
• Includes support for regular expressions which are convenient
  for complex searching.



                                                                  4
History of UNIX
• 1964 joint project between AT&T Bell Labs, GE, and MIT to
  develop a new OS.

• Goal : develop an OS that could provide computational
  power, data storage and the ability to share data among
  multiple users.

• Result: Multiplexed Information & Computer Service -
  MULTICS.



                                                          5
• 1969 Bell Labs withdraws from group.
• Two Bell Lab scientists, Ken Thompson and Dennis Ritchie,
  continue research. They were still left without a “Convenient
  interactive computing service”*.
• At the same time Ken Thompson wrote a game “space
  travel” in Fortran to run on GECOS OS.
• The spaceship was hard to control and it was expensive to
  run. He was told to get the game off his work computer.




                                                             6
• Thompson ported the game to a little used PDP-7 computer.
• Unics (later Unix) was born as a pun on Multics.
• Dennis Ritchie developed “B” . Then wrote “C” a compiled
  language.
• In 1973 entire OS ported to “C”.
• 1991 Linux 0.02 is first released to the public.
• 1994 Linux 1.0 is released.



                                                         7
Memory Management

 UNIX is machine independent so its memory management
  scheme will vary from one system to next.
 Early versions of UNIX used variable partitioning with no
  virtual memory scheme.
 Current implementations of UNIX make use of paged virtual
  memory.
 There are two memory management schemes :
       Paging System
       Kernal Memory Allocator



                                                         8
Virtual Memory




                 9
Memory Management policies


• Swapping
  – Easy to implement
  – Less system overhead


• Demand Paging
  – Greater Flexibility



                                     10
Swapping
• The process of moving some pages out of main memory and
  moving others in, is called swapping.
• A page fault occurs when the CPU tries to access a page that
  is not in main memory, thus forcing the CPU to wait for the
  page to be swapped in.
• Since moving data to and from disks takes a significant
  amount of time, the goal of the memory manager is to
  minimize the number of page faults.




                                                            11
• Swap Space - Disk memory used to hold data that is not in
  Real or File System memory. Swap space is most efficient
  when it is on a separate disk or partition, but sometimes it is
  just a large file in the File System.
• Allocation of both main memory and swap space is done
  first-fit.
• A page fault occurs when the CPU tries to access a page
  that is not in main memory, thus forcing the CPU to wait for
  the page to be swapped in.


                                                               12
• Since moving data to and from disks takes a significant
  amount of time, the goal of the memory manager is to
  minimize the number of page faults.
• When the size of a process' memory image increases (due to
  either stack expansion or data expansion), a new piece of
  memory big enough for the whole image is allocated.
• If no single piece of main memory is large enough, the
  process is swapped out such that it will be swapped back in
  with the new size.


                                                           13
• Decisions regarding which processes to swap in or swap out
  are made by the scheduler process (also known as the
  swapper).
• A process is more likely to be swapped out if it is idle or has
  been in main memory for a long time, or is large ; if no
  obvious candidates are found, other processes are picked by
  age.
• A process is more likely to be swapped in if its has been
  swapped out a long time, or is small.


                                                               14
15
Allocating Swap Space
Address     Unit
                   Allocate 100 unit
1         10000                            101        9900
      Map

                                   Allocate 50 unit



                   Allocate 100 unit
251         9850                          151         9750


                                                             16
Freeing Swap Space
  Address           Unit
                                50 unit free at 101
  251              9750                                  101    50

           Map                                           251   9750




Case 1: Free resources fill a hole,
        but not contiguous to any resources in the map


                                                                      17
Freeing Swap Space
    Address             Unit
                                 50 unit free at 101        101         50
     251             9750
                                                            251        9750
             Map
                                                  100 unit free at 1


                                                            1           150

Case 2: Free resources fill a hole,
                                                            251        9750
   and immediately precedes an entry in the map


                                                                              18
Freeing Swap Space
Address          Unit                              101              50
                         50 unit free at 101
    251         9750                               251           9750
          Map
                                           100 unit free at 1


1                150     Allocate 200 unit          1              150

451             9550                                251           9750

            300 unit free at 151          Case 3: Free resources fill a
                                          hole, and completely fills the
1          10000                          gap between entries in the
                                          map                              19
Demand Paging

• Demand paging to unix with BSD(Berkley system) which
  transferred memory pages instead of process to and from a
  secondary device.

• When a process needs a page and the page is not there, a
  page fault to the kernel occurs a frame of main memory is
  allocated, and the process is loaded into the frame by the
  kernel.



                                                          20
Page Table
   Page Frame   Age   Copy on Modify Reference   Valid   Protect
    Number             write


• frame # contains the physical frame where the virtual page
  is stored
• age is processor dependant, and is meant to maintain how
  long it has been since the page was accessed.
• Copy on Write store the copy on write bit, which is used in
  UNIX systems to, among other things, render fork efficient.


                                                              21
• Dirty is a single bit that indicates whether a page has been
  modified since last swapped in (the opposite of dirty is clean,
  and a clean page need not be written out to disk if
  swapped).
• Ref contains the usage information necessary for a CLOCK-
  style algorithm.
• Valid is the standard UNIX jargon for resident. A valid page
  is in main memory, an invalid one is swapped out.
• Protect contains the permission information for the page
  and is also hardware dependant.


                                                               22
Disk block descriptor

 Swap device Number Device Block No.      Type of storage


• The disk block descriptor contains the information mapping
  a virtual page to a spot on disk.
• The OS maintains a table of descriptors for each process.




                                                            23
• Device # is basically a pointer to the disk that this page was
  swapped to.
• Block # is the actual block that the page is stored on. This is
  why most UNIX systems prefer to have a separate swap
  partition, so that the block size can be set to the page size.
• Type specifies whether the page is new or pre-existing. This
  lets the OS know if it has to clear the frame first.




                                                               24
Page frame data table

     Page State   Reference   Logical    Block   Pf data
                   Count      device    number   pointer



• The page frame data table holds information about each
  physical frame of memory (indexed by frame number).
• This table is of primary importance for the replacement
  algorithm.

                                                            25
• Page state indicates whether or not the frame is available or
  has an associated page (i.e. whether its been allocated to a
  process or not).
• Ref. Count holds the number of processes that refer to this
  page (remember, processes can share the same physical
  page).
• Logical device contains the device number of the disk that
  holds a physical copy of the page.



                                                              26
• Block # holds the block number on that disk where the
  page data is located.

• Pfdata pointer is a pointer field that is used to thread a
  singly-linked list of free frames through the frame table. If
  the page is free, this points to the next free page (useful for
  free list-style allocation).



                                                                    27
Swap use table

             Reference      Page/storage
             count          unit number



• Reference Count : Number of page table entries that point
  to a page on the swap device.
• Page/storage unit number : Page identifier on storage unit



                                                               28
Page Replacement Algorithm

• The Page frame data table is used for page replacement.

• All of the available frames are linked together in a list of free
  frames available for bringing in pages.

• The two-handed clock algorithm uses the reference bit in the
  page table entry for each page in memory that is eligible
  (not locked) to be swapped out.

• This bit is set to 0 when when the page is first brought in and
  set to 1 when the page is refernced for a read or write .
                                                                 29
Two-Handed clock Page Replacement Algorithm




                                              30
• Two parameters determine the operation of the algorithm:

   – Scanrate: The rate at which the two hands scan through the
     page list, in pages per second.
   – Handspread: The gap between fronthand and backhand

• These two parameters have default values set at boot time
  based on the amount of physical memory.




                                               31
• The parameter varies linearly between the values slowscan
  and fastscan as the amount of free memory varies between
  the values lotsfree and minfree.

• The handspread parameter determines the gap between the
  fronthand and the backhand and therefore, together with
  scanrate,determines the window of oppurtunity to use a
  page before it is swapped out due to lack of use.



                                                              32
Kernal Memory Allocator
• Kernel memory allocator: provides buffers of memory to
  various kernel subsytems.

Evolution Criteria :
   – must be space-efficient i.e. minimize wastage.
   – Can be measured by utilization factor
   – must be fast
   – must have a simple programming interface
   – should not force to free the entire allocated area all at once
   – must guard against the wastage of memory
   – must be able to interact with the paging system
                                                                      33
Advantages
• easy to implement
• not restricted to memory allocation
• no wastage of space
• can release any part of the region
• allows reuse of memory by coalescing



                                         34
References
Books :
*********
1. Os Internals & design
                --- William Stallings
2. The design of the unix operating system
                --- Maurice J. Bach prentice hall




                                                    35

Mais conteúdo relacionado

Mais procurados

Operating systems system structures
Operating systems   system structuresOperating systems   system structures
Operating systems system structuresMukesh Chinta
 
Process management in os
Process management in osProcess management in os
Process management in osMiong Lazaro
 
Operating system 24 mutex locks and semaphores
Operating system 24 mutex locks and semaphoresOperating system 24 mutex locks and semaphores
Operating system 24 mutex locks and semaphoresVaibhav Khanna
 
file system in operating system
file system in operating systemfile system in operating system
file system in operating systemtittuajay
 
Os unit 3 , process management
Os unit 3 , process managementOs unit 3 , process management
Os unit 3 , process managementArnav Chowdhury
 
Operating Systems - "Chapter 4: Multithreaded Programming"
Operating Systems - "Chapter 4:  Multithreaded Programming"Operating Systems - "Chapter 4:  Multithreaded Programming"
Operating Systems - "Chapter 4: Multithreaded Programming"Ra'Fat Al-Msie'deen
 
Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)Mukesh Chinta
 
Processes in unix
Processes in unixProcesses in unix
Processes in unixmiau_max
 
Kernel. Operating System
Kernel. Operating SystemKernel. Operating System
Kernel. Operating Systempratikkadam78
 
File system Os
File system OsFile system Os
File system OsNehal Naik
 
Ch02 early system memory management
Ch02 early system  memory managementCh02 early system  memory management
Ch02 early system memory managementJacob Cadeliña
 
Operating Systems: Process Scheduling
Operating Systems: Process SchedulingOperating Systems: Process Scheduling
Operating Systems: Process SchedulingDamian T. Gordon
 
8 memory management strategies
8 memory management strategies8 memory management strategies
8 memory management strategiesDr. Loganathan R
 
Distributed operating system
Distributed operating systemDistributed operating system
Distributed operating systemPrankit Mishra
 

Mais procurados (20)

Operating systems system structures
Operating systems   system structuresOperating systems   system structures
Operating systems system structures
 
Process management in os
Process management in osProcess management in os
Process management in os
 
Kernels and its types
Kernels and its typesKernels and its types
Kernels and its types
 
Os Threads
Os ThreadsOs Threads
Os Threads
 
Linux Memory Management
Linux Memory ManagementLinux Memory Management
Linux Memory Management
 
Operating system 24 mutex locks and semaphores
Operating system 24 mutex locks and semaphoresOperating system 24 mutex locks and semaphores
Operating system 24 mutex locks and semaphores
 
file system in operating system
file system in operating systemfile system in operating system
file system in operating system
 
Os unit 3 , process management
Os unit 3 , process managementOs unit 3 , process management
Os unit 3 , process management
 
Operating Systems - "Chapter 4: Multithreaded Programming"
Operating Systems - "Chapter 4:  Multithreaded Programming"Operating Systems - "Chapter 4:  Multithreaded Programming"
Operating Systems - "Chapter 4: Multithreaded Programming"
 
Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)
 
Processes in unix
Processes in unixProcesses in unix
Processes in unix
 
Distributed Operating System_1
Distributed Operating System_1Distributed Operating System_1
Distributed Operating System_1
 
Virtual machine
Virtual machineVirtual machine
Virtual machine
 
CPU Scheduling Algorithms
CPU Scheduling AlgorithmsCPU Scheduling Algorithms
CPU Scheduling Algorithms
 
Kernel. Operating System
Kernel. Operating SystemKernel. Operating System
Kernel. Operating System
 
File system Os
File system OsFile system Os
File system Os
 
Ch02 early system memory management
Ch02 early system  memory managementCh02 early system  memory management
Ch02 early system memory management
 
Operating Systems: Process Scheduling
Operating Systems: Process SchedulingOperating Systems: Process Scheduling
Operating Systems: Process Scheduling
 
8 memory management strategies
8 memory management strategies8 memory management strategies
8 memory management strategies
 
Distributed operating system
Distributed operating systemDistributed operating system
Distributed operating system
 

Destaque (8)

Unix Process management
Unix Process managementUnix Process management
Unix Process management
 
comparing windows and linux ppt
comparing windows and linux pptcomparing windows and linux ppt
comparing windows and linux ppt
 
Linux Introduction
Linux IntroductionLinux Introduction
Linux Introduction
 
Case study linux
Case study linuxCase study linux
Case study linux
 
Linux v/s Windows
Linux v/s WindowsLinux v/s Windows
Linux v/s Windows
 
Unix operating system
Unix operating systemUnix operating system
Unix operating system
 
Unix Operating System
Unix Operating SystemUnix Operating System
Unix Operating System
 
UNIX Operating System
UNIX Operating SystemUNIX Operating System
UNIX Operating System
 

Semelhante a Unix memory management

Manta: a new internet-facing object storage facility that features compute by...
Manta: a new internet-facing object storage facility that features compute by...Manta: a new internet-facing object storage facility that features compute by...
Manta: a new internet-facing object storage facility that features compute by...Hakka Labs
 
The Internet-of-things: Architecting for the deluge of data
The Internet-of-things: Architecting for the deluge of dataThe Internet-of-things: Architecting for the deluge of data
The Internet-of-things: Architecting for the deluge of databcantrill
 
Bringing the Unix Philosophy to Big Data
Bringing the Unix Philosophy to Big DataBringing the Unix Philosophy to Big Data
Bringing the Unix Philosophy to Big Databcantrill
 
INTRODUCTION TO PARALLEL PROCESSING
INTRODUCTION TO PARALLEL PROCESSINGINTRODUCTION TO PARALLEL PROCESSING
INTRODUCTION TO PARALLEL PROCESSINGGS Kosta
 
Introducing Plan9 from Bell Labs
Introducing Plan9 from Bell LabsIntroducing Plan9 from Bell Labs
Introducing Plan9 from Bell LabsAnant Narayanan
 
OS Slide Ch12 13
OS Slide Ch12 13OS Slide Ch12 13
OS Slide Ch12 13庭緯 陳
 
OpenStack & the Evolving Cloud Ecosystem
OpenStack & the Evolving Cloud EcosystemOpenStack & the Evolving Cloud Ecosystem
OpenStack & the Evolving Cloud EcosystemMark Voelker
 
The Rise of Cloud Computing Systems
The Rise of Cloud Computing SystemsThe Rise of Cloud Computing Systems
The Rise of Cloud Computing SystemsDaehyeok Kim
 
The building blocks of docker.
The building blocks of docker.The building blocks of docker.
The building blocks of docker.Chafik Belhaoues
 
CS403: Operating System : Lec 7 OS Properties.pptx
CS403: Operating System : Lec 7 OS Properties.pptxCS403: Operating System : Lec 7 OS Properties.pptx
CS403: Operating System : Lec 7 OS Properties.pptxAsst.prof M.Gokilavani
 
Xen and the Art of Virtualization
Xen and the Art of VirtualizationXen and the Art of Virtualization
Xen and the Art of VirtualizationSusheel Thakur
 
Disk Management through the Computer Management
Disk Management through the Computer ManagementDisk Management through the Computer Management
Disk Management through the Computer ManagementAnshGoyal32
 

Semelhante a Unix memory management (20)

Manta: a new internet-facing object storage facility that features compute by...
Manta: a new internet-facing object storage facility that features compute by...Manta: a new internet-facing object storage facility that features compute by...
Manta: a new internet-facing object storage facility that features compute by...
 
The Internet-of-things: Architecting for the deluge of data
The Internet-of-things: Architecting for the deluge of dataThe Internet-of-things: Architecting for the deluge of data
The Internet-of-things: Architecting for the deluge of data
 
Bringing the Unix Philosophy to Big Data
Bringing the Unix Philosophy to Big DataBringing the Unix Philosophy to Big Data
Bringing the Unix Philosophy to Big Data
 
os
osos
os
 
Module5 secondary storage
Module5 secondary storageModule5 secondary storage
Module5 secondary storage
 
Factored operating systems
Factored operating systemsFactored operating systems
Factored operating systems
 
INTRODUCTION TO PARALLEL PROCESSING
INTRODUCTION TO PARALLEL PROCESSINGINTRODUCTION TO PARALLEL PROCESSING
INTRODUCTION TO PARALLEL PROCESSING
 
Os
OsOs
Os
 
Introducing Plan9 from Bell Labs
Introducing Plan9 from Bell LabsIntroducing Plan9 from Bell Labs
Introducing Plan9 from Bell Labs
 
OS Slide Ch12 13
OS Slide Ch12 13OS Slide Ch12 13
OS Slide Ch12 13
 
OpenStack & the Evolving Cloud Ecosystem
OpenStack & the Evolving Cloud EcosystemOpenStack & the Evolving Cloud Ecosystem
OpenStack & the Evolving Cloud Ecosystem
 
The Rise of Cloud Computing Systems
The Rise of Cloud Computing SystemsThe Rise of Cloud Computing Systems
The Rise of Cloud Computing Systems
 
Disk Architecture.pptx
Disk Architecture.pptxDisk Architecture.pptx
Disk Architecture.pptx
 
The building blocks of docker.
The building blocks of docker.The building blocks of docker.
The building blocks of docker.
 
CS403: Operating System : Lec 7 OS Properties.pptx
CS403: Operating System : Lec 7 OS Properties.pptxCS403: Operating System : Lec 7 OS Properties.pptx
CS403: Operating System : Lec 7 OS Properties.pptx
 
Xen and the Art of Virtualization
Xen and the Art of VirtualizationXen and the Art of Virtualization
Xen and the Art of Virtualization
 
Unixfs
UnixfsUnixfs
Unixfs
 
18CSC205J-UNIT-5.pptx
18CSC205J-UNIT-5.pptx18CSC205J-UNIT-5.pptx
18CSC205J-UNIT-5.pptx
 
NASA's Movement Towards Cloud Computing
NASA's Movement Towards Cloud ComputingNASA's Movement Towards Cloud Computing
NASA's Movement Towards Cloud Computing
 
Disk Management through the Computer Management
Disk Management through the Computer ManagementDisk Management through the Computer Management
Disk Management through the Computer Management
 

Mais de Tech_MX

Virtual base class
Virtual base classVirtual base class
Virtual base classTech_MX
 
Theory of estimation
Theory of estimationTheory of estimation
Theory of estimationTech_MX
 
Templates in C++
Templates in C++Templates in C++
Templates in C++Tech_MX
 
String & its application
String & its applicationString & its application
String & its applicationTech_MX
 
Statistical quality__control_2
Statistical  quality__control_2Statistical  quality__control_2
Statistical quality__control_2Tech_MX
 
Stack data structure
Stack data structureStack data structure
Stack data structureTech_MX
 
Stack Data Structure & It's Application
Stack Data Structure & It's Application Stack Data Structure & It's Application
Stack Data Structure & It's Application Tech_MX
 
Spanning trees & applications
Spanning trees & applicationsSpanning trees & applications
Spanning trees & applicationsTech_MX
 
Set data structure 2
Set data structure 2Set data structure 2
Set data structure 2Tech_MX
 
Set data structure
Set data structure Set data structure
Set data structure Tech_MX
 
Real time Operating System
Real time Operating SystemReal time Operating System
Real time Operating SystemTech_MX
 
Mouse interrupts (Assembly Language & C)
Mouse interrupts (Assembly Language & C)Mouse interrupts (Assembly Language & C)
Mouse interrupts (Assembly Language & C)Tech_MX
 
Motherboard of a pc
Motherboard of a pcMotherboard of a pc
Motherboard of a pcTech_MX
 
More on Lex
More on LexMore on Lex
More on LexTech_MX
 
MultiMedia dbms
MultiMedia dbmsMultiMedia dbms
MultiMedia dbmsTech_MX
 
Merging files (Data Structure)
Merging files (Data Structure)Merging files (Data Structure)
Merging files (Data Structure)Tech_MX
 
Memory dbms
Memory dbmsMemory dbms
Memory dbmsTech_MX
 

Mais de Tech_MX (20)

Virtual base class
Virtual base classVirtual base class
Virtual base class
 
Uid
UidUid
Uid
 
Theory of estimation
Theory of estimationTheory of estimation
Theory of estimation
 
Templates in C++
Templates in C++Templates in C++
Templates in C++
 
String & its application
String & its applicationString & its application
String & its application
 
Statistical quality__control_2
Statistical  quality__control_2Statistical  quality__control_2
Statistical quality__control_2
 
Stack data structure
Stack data structureStack data structure
Stack data structure
 
Stack Data Structure & It's Application
Stack Data Structure & It's Application Stack Data Structure & It's Application
Stack Data Structure & It's Application
 
Spss
SpssSpss
Spss
 
Spanning trees & applications
Spanning trees & applicationsSpanning trees & applications
Spanning trees & applications
 
Set data structure 2
Set data structure 2Set data structure 2
Set data structure 2
 
Set data structure
Set data structure Set data structure
Set data structure
 
Real time Operating System
Real time Operating SystemReal time Operating System
Real time Operating System
 
Parsing
ParsingParsing
Parsing
 
Mouse interrupts (Assembly Language & C)
Mouse interrupts (Assembly Language & C)Mouse interrupts (Assembly Language & C)
Mouse interrupts (Assembly Language & C)
 
Motherboard of a pc
Motherboard of a pcMotherboard of a pc
Motherboard of a pc
 
More on Lex
More on LexMore on Lex
More on Lex
 
MultiMedia dbms
MultiMedia dbmsMultiMedia dbms
MultiMedia dbms
 
Merging files (Data Structure)
Merging files (Data Structure)Merging files (Data Structure)
Merging files (Data Structure)
 
Memory dbms
Memory dbmsMemory dbms
Memory dbms
 

Último

HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfJemuel Francisco
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
FILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinoFILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinojohnmickonozaleda
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptxSherlyMaeNeri
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 

Último (20)

HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
FILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinoFILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipino
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 

Unix memory management

  • 2. AGENDA  Introduction  History of UNIX  Swapping  Demand Paging Page Replacement Algorithm  Kernel Memory Allocator  Conclusion 2
  • 3. Introduction  UNIX is a portable, multi-tasking and multi-user operating system. – Portable: runs on many different hardware architectures (Intel x86 and IA-64, Alpha, MIPS, HP PA-RISC, PowerPC, IBM S/390, SPARC, Motorola 680x0, etc.). – Preemptive multi-tasking: several programs can run at the same time (time slices, interrupts, and task switching). – Multi-user: many users can share the computer system at the same time. 3
  • 4. Other Features… • Uses a simple, uniform file model which includes devices and access to other services in a flexible, hierarchical file system. • Written in a high-level language (“C”) making it easy to read, understand, change and port. • The command prompt is a simple user process, the Unix shell, which is also a convenient job programming language. • Includes support for regular expressions which are convenient for complex searching. 4
  • 5. History of UNIX • 1964 joint project between AT&T Bell Labs, GE, and MIT to develop a new OS. • Goal : develop an OS that could provide computational power, data storage and the ability to share data among multiple users. • Result: Multiplexed Information & Computer Service - MULTICS. 5
  • 6. • 1969 Bell Labs withdraws from group. • Two Bell Lab scientists, Ken Thompson and Dennis Ritchie, continue research. They were still left without a “Convenient interactive computing service”*. • At the same time Ken Thompson wrote a game “space travel” in Fortran to run on GECOS OS. • The spaceship was hard to control and it was expensive to run. He was told to get the game off his work computer. 6
  • 7. • Thompson ported the game to a little used PDP-7 computer. • Unics (later Unix) was born as a pun on Multics. • Dennis Ritchie developed “B” . Then wrote “C” a compiled language. • In 1973 entire OS ported to “C”. • 1991 Linux 0.02 is first released to the public. • 1994 Linux 1.0 is released. 7
  • 8. Memory Management  UNIX is machine independent so its memory management scheme will vary from one system to next.  Early versions of UNIX used variable partitioning with no virtual memory scheme.  Current implementations of UNIX make use of paged virtual memory.  There are two memory management schemes :  Paging System  Kernal Memory Allocator 8
  • 10. Memory Management policies • Swapping – Easy to implement – Less system overhead • Demand Paging – Greater Flexibility 10
  • 11. Swapping • The process of moving some pages out of main memory and moving others in, is called swapping. • A page fault occurs when the CPU tries to access a page that is not in main memory, thus forcing the CPU to wait for the page to be swapped in. • Since moving data to and from disks takes a significant amount of time, the goal of the memory manager is to minimize the number of page faults. 11
  • 12. • Swap Space - Disk memory used to hold data that is not in Real or File System memory. Swap space is most efficient when it is on a separate disk or partition, but sometimes it is just a large file in the File System. • Allocation of both main memory and swap space is done first-fit. • A page fault occurs when the CPU tries to access a page that is not in main memory, thus forcing the CPU to wait for the page to be swapped in. 12
  • 13. • Since moving data to and from disks takes a significant amount of time, the goal of the memory manager is to minimize the number of page faults. • When the size of a process' memory image increases (due to either stack expansion or data expansion), a new piece of memory big enough for the whole image is allocated. • If no single piece of main memory is large enough, the process is swapped out such that it will be swapped back in with the new size. 13
  • 14. • Decisions regarding which processes to swap in or swap out are made by the scheduler process (also known as the swapper). • A process is more likely to be swapped out if it is idle or has been in main memory for a long time, or is large ; if no obvious candidates are found, other processes are picked by age. • A process is more likely to be swapped in if its has been swapped out a long time, or is small. 14
  • 15. 15
  • 16. Allocating Swap Space Address Unit Allocate 100 unit 1 10000 101 9900 Map Allocate 50 unit Allocate 100 unit 251 9850 151 9750 16
  • 17. Freeing Swap Space Address Unit 50 unit free at 101 251 9750 101 50 Map 251 9750 Case 1: Free resources fill a hole, but not contiguous to any resources in the map 17
  • 18. Freeing Swap Space Address Unit 50 unit free at 101 101 50 251 9750 251 9750 Map 100 unit free at 1 1 150 Case 2: Free resources fill a hole, 251 9750 and immediately precedes an entry in the map 18
  • 19. Freeing Swap Space Address Unit 101 50 50 unit free at 101 251 9750 251 9750 Map 100 unit free at 1 1 150 Allocate 200 unit 1 150 451 9550 251 9750 300 unit free at 151 Case 3: Free resources fill a hole, and completely fills the 1 10000 gap between entries in the map 19
  • 20. Demand Paging • Demand paging to unix with BSD(Berkley system) which transferred memory pages instead of process to and from a secondary device. • When a process needs a page and the page is not there, a page fault to the kernel occurs a frame of main memory is allocated, and the process is loaded into the frame by the kernel. 20
  • 21. Page Table Page Frame Age Copy on Modify Reference Valid Protect Number write • frame # contains the physical frame where the virtual page is stored • age is processor dependant, and is meant to maintain how long it has been since the page was accessed. • Copy on Write store the copy on write bit, which is used in UNIX systems to, among other things, render fork efficient. 21
  • 22. • Dirty is a single bit that indicates whether a page has been modified since last swapped in (the opposite of dirty is clean, and a clean page need not be written out to disk if swapped). • Ref contains the usage information necessary for a CLOCK- style algorithm. • Valid is the standard UNIX jargon for resident. A valid page is in main memory, an invalid one is swapped out. • Protect contains the permission information for the page and is also hardware dependant. 22
  • 23. Disk block descriptor Swap device Number Device Block No. Type of storage • The disk block descriptor contains the information mapping a virtual page to a spot on disk. • The OS maintains a table of descriptors for each process. 23
  • 24. • Device # is basically a pointer to the disk that this page was swapped to. • Block # is the actual block that the page is stored on. This is why most UNIX systems prefer to have a separate swap partition, so that the block size can be set to the page size. • Type specifies whether the page is new or pre-existing. This lets the OS know if it has to clear the frame first. 24
  • 25. Page frame data table Page State Reference Logical Block Pf data Count device number pointer • The page frame data table holds information about each physical frame of memory (indexed by frame number). • This table is of primary importance for the replacement algorithm. 25
  • 26. • Page state indicates whether or not the frame is available or has an associated page (i.e. whether its been allocated to a process or not). • Ref. Count holds the number of processes that refer to this page (remember, processes can share the same physical page). • Logical device contains the device number of the disk that holds a physical copy of the page. 26
  • 27. • Block # holds the block number on that disk where the page data is located. • Pfdata pointer is a pointer field that is used to thread a singly-linked list of free frames through the frame table. If the page is free, this points to the next free page (useful for free list-style allocation). 27
  • 28. Swap use table Reference Page/storage count unit number • Reference Count : Number of page table entries that point to a page on the swap device. • Page/storage unit number : Page identifier on storage unit 28
  • 29. Page Replacement Algorithm • The Page frame data table is used for page replacement. • All of the available frames are linked together in a list of free frames available for bringing in pages. • The two-handed clock algorithm uses the reference bit in the page table entry for each page in memory that is eligible (not locked) to be swapped out. • This bit is set to 0 when when the page is first brought in and set to 1 when the page is refernced for a read or write . 29
  • 30. Two-Handed clock Page Replacement Algorithm 30
  • 31. • Two parameters determine the operation of the algorithm: – Scanrate: The rate at which the two hands scan through the page list, in pages per second. – Handspread: The gap between fronthand and backhand • These two parameters have default values set at boot time based on the amount of physical memory. 31
  • 32. • The parameter varies linearly between the values slowscan and fastscan as the amount of free memory varies between the values lotsfree and minfree. • The handspread parameter determines the gap between the fronthand and the backhand and therefore, together with scanrate,determines the window of oppurtunity to use a page before it is swapped out due to lack of use. 32
  • 33. Kernal Memory Allocator • Kernel memory allocator: provides buffers of memory to various kernel subsytems. Evolution Criteria : – must be space-efficient i.e. minimize wastage. – Can be measured by utilization factor – must be fast – must have a simple programming interface – should not force to free the entire allocated area all at once – must guard against the wastage of memory – must be able to interact with the paging system 33
  • 34. Advantages • easy to implement • not restricted to memory allocation • no wastage of space • can release any part of the region • allows reuse of memory by coalescing 34
  • 35. References Books : ********* 1. Os Internals & design --- William Stallings 2. The design of the unix operating system --- Maurice J. Bach prentice hall 35