Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 4: Process Memory Layout

Similar presentations


Presentation on theme: "Lecture 4: Process Memory Layout"— Presentation transcript:

1 Lecture 4: Process Memory Layout

2 Review: Unix File Access Control
Subject Users(owner, group, others) Object Directory/File Actions read write execute Each file has associated with it a set of access permissions indicating, for each of three classes of principals, what sorts of operations on the file are allowed. The three classes are the owner of the file, known as user, the group owner of the file, known simply as group, and everyone else, known as others. The operations are grouped into the classes read, write, and execute, with their obvious meanings. The access permissions apply to directories as well as to ordinary files, though the meaning of execute for directories is not quite so obvious: one must have execute permission for a directory file in order to follow a path through it. The system, when checking permissions, first determines the smallest class of principals the requester belongs to: user (smallest), group, or others (largest). It then, within the chosen class, checks for appropriate permissions. Copyright © 2002 Thomas W. Doeppner. All rights reserved.

3 System Calls For File Management

4 System Calls For Directory Management

5 System Calls For Miscellaneous Tasks

6 In this lecture Process memory layout

7 Linux process memory layout
Stack Heap Static data Text (program) Address space or core image

8 Linux process memory layout
Stack: Automatically allocated and deallocated Local variables, parameters Heap: Manually allocated (malloc) and deallocated (free) Dynamic sized data structures Static data Global variables Text Program

9 An example int g; int main() { int a;
int*b = (int*)malloc(sizeof(int) *2); return 0; }

10 An example Stack, a Stack, b Heap, b_content Static data, g
Text (program)

11 Multiple processes in memory
Unused Stack Heap Static data Text (program) Process 1 Stack Heap Static data Text (program) Unused Process 2

12 Function Call int main() { int a; a=f(); } int f() { int a,b;
return (a*b); }

13 Stack Frame arguments return address stack frame pointer
Heap Static data Text (program) arguments return address stack frame pointer local variables To previous stack frame pointer To the point at which this function was called

14 Function Call Hierarchy
int f() { int a; a=10; return (a*g()); } int g() { int a; a=100; return (a); } int main() { int a; a=f(); }

15 Fibonacci Numbers int fib (int n) { if (n < 0) return 0;
return (fib(n-1)+fib(n-2)); } fib (3): how many stack frames?

16 Memory leakage Stack, a Stack, b (pointer) Heap, b_content
Static data, g Text (program)

17 Garbage Collection No need to explicitly deallocate memory i.e. no need for free() or equivalent No memory leaks Automatic Garbage Collection A key feature of Java is its garbage-collected heap

18 Summarizing Process memory layout Stack frame for function calls Stack
Heap Static data Text Stack frame for function calls


Download ppt "Lecture 4: Process Memory Layout"

Similar presentations


Ads by Google