ECS150 Discussion - PowerPoint PPT Presentation

1 / 22
About This Presentation
Title:

ECS150 Discussion

Description:

The MM process table is defined in this file, along with any ... This file contains all the global variables used by MM. ... Program Files in /usr/src/mm ... – PowerPoint PPT presentation

Number of Views:31
Avg rating:3.0/5.0
Slides: 23
Provided by: csln
Category:
Tags: discussion | ecs150 | mm

less

Transcript and Presenter's Notes

Title: ECS150 Discussion


1
ECS150 Discussion
  • 11/12/2004
  • Lynn Nguyen

2
Announcement
  • Written Homework is assigned
  • Program 2 is assigned (Team work)
  • Due date 12/10/2004 at 5pm
  • Signup sheet for HW1 will be posted in the
    basement outside the TA room after the discussion

3
MM in Minix - Overview
User Process
User Process
User Process
Init
. . . . . .
User Space
Policy
Memory Manager
File System
Terminal Task
Disk task
Clock Task
System Task
. . . . . .
Kernel Space
Process management
Mechanism
4
MM in Minix
Original Memory Allocation
Now A is forking a child id fork()
B
Search the hole list
A
MINIX
5
MM in Minix
As Child
After a FORK system call
B
B
Find the piece that is Big enough
A
A
Equal size initially
MINIX
6
MM in Minix
C
As Child
B
B
B
A
A
A
MINIX
MINIX
MINIX
After the child does an EXEC
7
MM in Minix
Remains same place till termination No swapped
out Never moved to another place No grow in the
allocated area No shrink in the allocated area
C
B
A
MINIX
8
MM in Minix
After Process C terminates
C
It gets de-allocated from the Memory
B
B
A
A
MINIX
MINIX
9
Memory Layout
Higher Memory Address
Stack
Data
Text
Lower Memory Address
10
Relationship
Stack
B
Data
A
Text
11
Process Tables
Memory Mgmt
FS
Process Mgmt
Process A
Process A
Process A
K
One-to-one relationship
12
Header Files in /usr/src/mm
13
mproc
  • Array mp_seg
  • Struct for text
  • Virtual address
  • Physical address
  • Length of the segment
  • Struct for data
  • Virtual address
  • Physical address
  • Length of the segment
  • Struct for Stack
  • Virtual address
  • Physical address
  • Length of the segment

14
/usr/src/mm/mproc.h
/ This table has one slot per process. It
contains all the memory management information
for each process. Among other things, it defines
the text, data and stack segments, uids and
gids, and various flags. The kernel and file
systems have tables that are also indexed by
process, with the contents of corresponding
slots referring to the same process in all
three. / EXTERN struct mproc struct mem_map
mp_segNR_SEGS/ points to text, data, stack
/ char mp_exitstatus / storage for status when
process exits / char mp_sigstatus / storage
for signal for killed procs / pid_t mp_pid /
process id / pid_t mp_procgrp / pid of process
group (used for signals) / pid_t mp_wpid / pid
this process is waiting for / int mp_parent /
index of parent process / code omitted
... message mp_reply / reply message to be sent
to one / mprocNR_PROCS
15
/usr/include/minix/const.h
define NR_SEGS 3 / segments per
process/ define T 0 /proci.mem_mapT
is for text/ define D 1 /proci.mem_mapD
is for data/ define S 2
/proci.mem_mapS is for stack/
16
/usr/include/minix/type.h
ifndef _TYPE_H define _TYPE_H ifndef
_MINIX_TYPE_H define _MINIX_TYPE_H / Type
definitions. / typedef unsigned int vir_clicks
/ virtual addresses and lengths in clicks
/ typedef unsigned long phys_bytes/ physical
addresses and lengths in bytes / typedef
unsigned int phys_clicks/ physical addresses
and lengths in clicks / struct mem_map
vir_clicks mem_vir / virtual address
/ phys_clicks mem_phys / physical address
/ vir_clicks mem_len / length /
17
Program Files in /usr/src/mm
18
Program Files in /usr/src/mm
19
Memory Allocation/usr/src/mm/alloc.c
define NR_HOLES 128 / max entries in hole
table / ... PRIVATE struct hole phys_clicks
h_base / where does the hole begin?
/ phys_clicks h_len / how big is the hole?
/ struct hole h_next / pointer to next entry
on the list / holeNR_HOLES ... PRIVATE
struct hole hole_head / pointer to first hole
/ /Function alloc_mem/ hp hole_head while(
hp ! NIL_HOLE ) ... prev_ptr hp hp
hp-gth_next
20
Program 2 Overview
  • Struct MemSeq memdump (int PID)
  • Struct MemSeq
  • int PID
  • unsigned int addr_begin
  • unsigned int addr_end
  • struct MemSeq Next
  • Return value
  • if (PID ! 0)
  • return the range of mem addr for PID process
  • next NULL if PID is valid
  • else
  • return addr_begin and addr_end for ALL the user
    process
  • next for the last user process should be NULL

21
(No Transcript)
22
Useful command
  • Grep for pattern match
  • Usage grep PATTERN FILE
  • Example
  • Search for the string mem_map in directory
    /usr/src/kernel among all the files
  • grep mem_map
  • Does not work hierarchicaly
  • CAN NOT DO
  • search for the string mem_map in diretory
  • /usr/src/
Write a Comment
User Comments (0)
About PowerShow.com