MInix memory management1 Minix Memory Management. Contiguous memory management. No swapping. A list of holes sorted in memory address order is maintained.

Slides:



Advertisements
Similar presentations
R4 Dynamically loading processes. Overview R4 is closely related to R3, much of what you have written for R3 applies to R4 In R3, we executed procedures.
Advertisements

1 CS345 Operating Systems Φροντιστήριο Άσκησης 1.
Module R2 Overview. Process queues As processes enter the system and transition from state to state, they are stored queues. There may be many different.
Module R2 CS450. Next Week R1 is due next Friday ▫Bring manuals in a binder - make sure to have a cover page with group number, module, and date. You.
CSCC69: Operating Systems
Unix-v5 Process Structure
UNIX Process Control Bach 7 Operating Systems Course Hebrew University Spring 2007.
11/15/2005Comp 120 Fall November Seven Classes to Go! Questions! VM and Making Programs Go.
Processes CSCI 444/544 Operating Systems Fall 2008.
Memory Management Policies: UNIX
Introduction to Kernel
Inter Process Communication:  It is an essential aspect of process management. By allowing processes to communicate with each other: 1.We can synchronize.
Advanced OS Chapter 3p2 Sections 3.4 / 3.5. Interrupts These enable software to respond to signals from hardware. The set of instructions to be executed.
Memory Management Chapter 5.
Process in Unix, Linux and Windows CS-3013 C-term Processes in Unix, Linux, and Windows CS-3013 Operating Systems (Slides include materials from.
CS-502 Fall 2006Processes in Unix, Linux, & Windows 1 Processes in Unix, Linux, and Windows CS502 Operating Systems.
CSE 451 Section 4 Project 2 Design Considerations.
Memory Allocation CS Introduction to Operating Systems.
Operating System Chapter 7. Memory Management Lynn Choi School of Electrical Engineering.
CS 6560 Operating System Design Lecture 13 Finish File Systems Block I/O Layer.
Process in Unix, Linux, and Windows CS-3013 A-term Processes in Unix, Linux, and Windows CS-3013 Operating Systems (Slides include materials from.
Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall, Inc. All rights reserved OPERATING SYSTEMS DESIGN.
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-7 Memory Management (1) Department of Computer Science and Software.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 8: Main Memory.
Introduction to Processes CS Intoduction to Operating Systems.
Exec Function calls Used to begin a processes execution. Accomplished by overwriting process imaged of caller with that of called. Several flavors, use.
Memory Management Techniques
VIRTUAL MEMORY By Thi Nguyen. Motivation  In early time, the main memory was not large enough to store and execute complex program as higher level languages.
CS 149: Operating Systems March 3 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak
System calls for Process management
By Teacher Asma Aleisa Year 1433 H.   Goals of memory management  To provide a convenient abstraction for programming.  To allocate scarce memory.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 9: Virtual Memory.
1 Memory Management Chapter 7. 2 Memory Management Subdividing memory to accommodate multiple processes Memory needs to be allocated to ensure a reasonable.
Operating Systems Process Creation
CS4315A. Berrached:CMS:UHD1 Process Management Chapter 6.
Processes and Virtual Memory
Programs and Processes. The Virtual Address Space A typical process VAS space includes: user regions in the lower half V->P mappings specific to each.
CSCI 156: Lab 11 Paging. Our Simple Architecture Logical memory space for a process consists of 16 pages of 4k bytes each. Your program thinks it has.
System calls for Process management Process creation, termination, waiting.
COMP091 – Operating Systems 1 Memory Management. Memory Management Terms Physical address –Actual address as seen by memory unit Logical address –Address.
Direct memory access. IO Command includes: buffer address buffer length read or write dada position in disk When IO complete, DMA sends an interrupt request.
Memory Management Chapter 5 Advanced Operating System.
Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Chapter 2: The Linux System Part 4.
Memory management The main purpose of a computer system is to execute programs. These programs, together with the data they access, must be in main memory.
Chapter 8: Memory Management. 8.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 8: Memory Management Background Swapping Contiguous.
A process is a program in execution A running system consists of multiple processes – OS processes Processes started by the OS to do “system things” –
Chapter 2: The Linux System Part 4
Memory Management.
Chapter 2 Memory and process management
Requirements, Partitioning, paging, and segmentation
Chapter 9: Virtual Memory
Using Processes.
Processes A process is a running program.
Processes in Unix, Linux, and Windows
Main Memory Management
CS Introduction to Operating Systems
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 8 11/24/2018.
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 9 12/1/2018.
Main Memory Background Swapping Contiguous Allocation Paging
Memory Allocation CS 217.
Lecture 3: Main Memory.
Operating System Chapter 7. Memory Management
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 9 4/5/2019.
Virtual Memory: Systems CSCI 380: Operating Systems
CSCI 380: Operating Systems William Killian
Processes in Unix and Windows
Process Description and Control in Unix
Process Description and Control in Unix
CSE 542: Operating Systems
Presentation transcript:

MInix memory management1 Minix Memory Management. Contiguous memory management. No swapping. A list of holes sorted in memory address order is maintained.

MInix memory management2 Memory Allocation. Memory is allocated during: –FORK and EXEC system calls. When FORK or EXEC is executed, the hole list is searched using first fit for a hole that is big enough. Once the process is placed in memory, it remains in exactly the same place until it terminates.

MInix memory management3 Where is the memory management located in the Minix structure? How does the memory manager communicate with other parts of the system?

MInix memory management4 Memory Layout. Minix processes can use either combined I and D space or separate I and D space. What is I and D space? Processes using separate I and D space can use memory more efficiently. WHY?

MInix memory management5 Allocation and de-allocation of memory. Memory segment is allocated when: –FORK or EXEC is executed Memory segment is de-allocated when: – a process terminates –EXEC is successful after the FORK; I.e.memory allocated to the FORK is released.

MInix memory management6 Amount of memory allocated. Memory manager allocates the amount of main memory specified in the file’s header. For files using separate I and D space, only enough memory for stack and data is allocated during a FORK call. (The child’s and parent’s text memory is shared.)

MInix memory management7 Program stored on the disk. The executable file stored on the disk consists of the following components: Symbols table (used for debugging) Data Text Header

MInix memory management8 Program stored in main memory. The executable file stored in main memory consists of the following components: Stack Gap (for stack and data to grow) Data + bss Text

MInix memory management9 The file header. The file header contains the information about sizes of all components of the executable file (data+bss, text and stack) It contains a bit indicating whether I and D are separate or not. The total field of the header specifies the total amount of memory allocated to the process.

MInix memory management10 Changing the value of total. If the programmer knows that the total memory needed for the combined growth of the data and stack segments for the file a.out is at most 10K, he/she can give a command: $ chmem a.out

MInix memory management11 BRK and SBRK system calls. BRK and SBRK change the boundary between data and stack. char* addr1; char* addr2; int brkResult; addr1 = sbrk(0); printf("Current break: %#x\n", addr1); brkResult = brk(addr );

MInix memory management12 Messages. Memory manager is message driven. It awaits messages and takes actions upon receiving messages. The following message types are received by MM: –FORK, EXIT, WAIT, WAITPID, BRK –KILL, ALARM, SIGACTION –GETUID, GETPID, SETUID, SETGID

MInix memory management13 Data Structures. The MM has two main data structures: –process table and hole table MM process table is defined in: –usr/src/mm/mproc.h (line 16300) – the most important field is the array mp_seg, which has three entries for text, data and stack. –each entry is a structure that defines the virtual address, physical address, and the length of the segment.

MInix memory management14 Review mproc structure. What are other fields in it and what is their meaning?

MInix memory management15 Clicks. Memory is allocated using memory clicks. The size of a memory click is implementation dependent and in standard MINIX is 256 bytes. WHY?

MInix memory management16 Hole Table. Hole table is defined in src/mm/alloc.c #define NR_HOLES 128/* max # entries in hole table */ #define NIL_HOLE (struct hole *) 0 PRIVATE struct hole { phys_clicks h_base;/* where does the hole begin? */ phys_clicks h_len;/* how big is the hole? */ int h_free_mark; struct hole *h_next;/* pointer to next entry on the list */ } hole[NR_HOLES];

MInix memory management17 Operation of the Hole List The hole list is searched using first fit. The segment is allocated by reducing the hole size by the amount of memory allocated to the process. When a process is terminated, the memory segment used by it is placed back on the hole list. Adjacent holes are merged to create a single hole.

MInix memory management18 FORK’s algorithm. FORK creates a process by executing the following steps: –check to see if process table is full –allocate memory for the child’s process –copy parent’s data+stack and text to child’s memory –find a free process slot and copy parent’s slot to it. –enter child’s memory map in process table –choose pid for the child –tell kernel and file system about the child –report child’s memory map to the kernel –send reply messages to parent and child

MInix memory management19 What is a zombie state of a process and when does it happen?

MInix memory management20 EXEC’s algorithm. EXEC is the most complex system call in MINIX. Here are the steps of EXEC: –check to see if the file is executable. –read the header to get the segment and the total sizes –fetch the arguments and environment from the caller –allocate new memory and release the unneeded memory –copy stack, data and text segments to the new memory image –check for and handle setuid, setgid bits –fix up process table entry –tell kernel that process is now runnable

MInix memory management21 Allocating memory for EXEC. The hole table is searched to find a hole that is big enough to hold a new process. The old memory image (created by FORK) is not released until after a hole big enough to hold a new process is found. This approach is overly strict. WHY?

MInix memory management22 Possible Improvement of EXEC Current strict approach can be improved by checking if enough of memory will be available after the amount allocated by FORK is released. This is your requirement for project 5.

MInix memory management23 Project 5 hints - MINIX source code usr/sys/mm/proto.h –If you plan do add functions to the MM module, you need to prototype the usr/sys/mm/proto.h usr/src/mm/exec.c –The new_mem function, which is called by do_exec, contains the logic that determines if the new process can fit in memory.

MInix memory management24 usr/src/mm/alloc.c –Structure hole, array hole, hole_head pointer and free_slots pointer are defined here. –Function free_mem called by new_mem is defined here. This function returns a block of free memory to the hole list. –Function merge is called by free_mem and it merges two adjacent holes into one.

MInix memory management25 Project 5 hints -memcpy Memcpy is a function that allows to perform a quick copy of parts of main memory –e.g : you can copy contents of array old_array to array new_array using the following syntax: memcpy(new_array, old_array, sizeof(old_array))

MInix memory management26 Project 5 hints -chmem In order to test if your MM module does better job than the current Minix MM you may choose to use command chmem which changes the size of the data and stack segment in an executable file and show that exec that failed before does not fail with new MM running E.G. –chmem myshell