DOC PREVIEW
CMU CS 15213 - Exam

This preview shows page 1-2-3-4 out of 12 pages.

Save
View full document
Premium Document
Do you want full access? Go Premium and unlock all 12 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

15 213 Introduction to Computer Systems Exam 2 April 10 2007 Name Andrew User ID Recitation Section This is an open book exam Notes and calculators are permitted but not computers Write your answer legibly in the space provided You have 80 minutes for this exam We will drop your lowest score among questions 1 6 Problem Max Score Symbols and Linking 1 15 Virtual Address Translation 2 15 Process Control 3 15 Signals 4 15 Garbage Collection 5 15 Cyclone 6 15 Total 75 1 1 Symbols and Linking 15 points In this problem we consider issues of symbols and linking Consider the following three files File polygon h struct Node float pos 2 int marked struct Node next struct Node prev typedef struct Node node only for GC node alloc void init void gc allocated new node initialize store call garbage collector File main c with portions of the function elided include polygon h node root ptr int main node p init p alloc root ptr p gc return 0 root pointer for GC GC root is first allocated pointer File gc c with function bodies elided include polygon h define N 1 20 static node polygon N static node free ptr static node root ptr polygon array free list root pointer for GC void mark node v void sweep void gc void init node alloc 2 Possible definition of the functions in gc c are revisited in Problems 5 and 6 although this is not relevant here Recall that a line include file will literally be replaced by the contents of file by the C preprocessor We compile the files to obtain an executable object file polygon with gcc o polygon main c gc c Questions related to symbols and linking therefore refer to the expanded versions of the files 1 9 points Fill in the following tables by stating for each name whether it is local or global and whether it is strong or weak Cross out any box in the table that does not apply For example cross out the first box in a line if the symbol is not in the symbol table or cross out the second box in a line if the symbol is not global and therefore neither weak nor strong main c Local or Global Strong or Weak root ptr init main gc c Local or Global Strong or Weak N polygon root ptr alloc 3 2 3 points Explain why linking succeeds to create an executable despite the fact that some symbols are declared in both files 3 3 points Explain why the executable fails to be correct despite the fact that it compiles and links without warning Propose how to fix the bug Be clear in your suggestion correction for example replace the line with 4 2 Virtual Address Translation 15 points In this problem we consider virtual address translation using a two level page table The parameters of the machine are as follows The memory is byte addressable Virtual addresses are 32 bits wide The 32 bits of the virtual address are divided into 8 bits for VPN1 8 bits for VPN2 and 16 bits for the VPO Physical addresses are 24 bits wide 1 3 pts Given the parameters above fill in the blanks below i The page size is ii The maximal physical memory size is iii Assuming a page table entry is 32 bits the size of a page table is Next we consider the behavior of address translation using the two level page table We assume that page table entries have the following form where unspecified bits are irrelevant for this problem Level 1 Bits 31 16 High 16 bits of level 2 page table physical base address Bit 0 1 Present in physical memory Level 2 Bits 31 24 PPN Bit 0 1 Present in physical memory For the following questions assume that the VPN is not cached in the TLB so we have to consult the page tables The PTBR is set at 0xC80000 Address Content Address Content 0xC80000 0xC80004 0xC80008 0xC8000C 0xCA1C0001 0xCA1B0000 0xCA1D0001 0xCA1B0001 0xCA1B00 0xCA1B04 0xCA1B08 0xCA1B0C 0x07000001 0xFF000000 0x08000001 0xCA000001 0xC80010 0xC80014 0xC80018 0xC8001C 0x00000000 0xCA1B0001 0xC8000000 0xCA1B0001 0xCA1B10 0xCA1B14 0xCA1B18 0xCA1B1C 0x01000000 0x00000000 0x09000001 0xCA000000 5 2 6 points For the virtual address 0x0300F218 indicate the physical address and various results of the translation If there is a page fault enter for the answer and all subsequent results All answers should be given in hexadecimal Parameter Value VPN1 VPN2 PTE level 1 Page Fault Y N PTE level 2 Page Fault Y N PPN Physical Address 3 6 points For the virtual address 0x0507EE00 indicate the physical address and various results of the translation If there is a page fault enter for the PPN and Physical Address All answers should be given in hexadecimal Parameter Value VPN1 VPN2 PTE level 1 Page Fault Y N PTE level 2 Page Fault Y N PPN Physical Address 6 3 Process Control 15 points Consider the following C program For space reasons we do not check return codes so assume that all functions return normally Also assume that printf is unbuffered and that each process successfully runs to completion int main int pid pid fork fork if pid printf A n else printf B n exit 0 Mark each column that represents a valid possible output of this program with Yes and each column which is impossible with No A A A A A A A A A A A B B A B B 7 4 Signals 15 points Consider the following code int val 1 void handler int sig waitpid 1 NULL 0 val int main int pid signal SIGCHLD handler pid fork if pid 0 val 0 exit 0 printf d n val exit 0 Assume that all system calls succeed and that all processes terminate normally List all possible outputs of this program 8 5 Garbage Collection 15 points In this problem we consider code for a specialized mark and sweep garbage collector a skeleton of which was introduced in Problem 1 We first explain the data structures A polygon is implemented as a doubly linked list of vertices where each vertex has a link to its successor and predecessor vertices the next and prev pointers respectively In addition the x and y position of each vertex are stored in pos 0 and pos 1 struct Node float pos 2 int marked struct Node next struct Node prev typedef struct Node node only for GC Finally we have a mark field marked which is used exclusively by the garbage collector and should not be touched by the user program For simplicity we store this as a whole int instead of as a bit There is a static array polygon of size N containing all vertices There is also a pointer to the beginning of a list of free vertices free ptr and a single root pointer root ptr pointing to the polygon The free pointer must be maintained by the garbage collector the root pointer is maintained by the user program and may not be changed by the garbage collector define N 1 20 node …


View Full Document

CMU CS 15213 - Exam

Documents in this Course
lecture

lecture

14 pages

lecture

lecture

46 pages

Caches

Caches

9 pages

lecture

lecture

39 pages

Lecture

Lecture

36 pages

Lecture

Lecture

45 pages

Lecture

Lecture

56 pages

lecture

lecture

11 pages

lecture

lecture

9 pages

Lecture

Lecture

36 pages

Lecture

Lecture

37 pages

Exam

Exam

16 pages

Lecture

Lecture

10 pages

Lecture

Lecture

43 pages

Lecture

Lecture

8 pages

Lecture

Lecture

8 pages

Lecture

Lecture

36 pages

Lecture

Lecture

43 pages

Lecture

Lecture

12 pages

Lecture

Lecture

37 pages

Lecture

Lecture

6 pages

Lecture

Lecture

40 pages

coding

coding

2 pages

Exam

Exam

17 pages

Exam

Exam

14 pages

Lecture

Lecture

29 pages

Lecture

Lecture

34 pages

Exam

Exam

11 pages

Lecture

Lecture

9 pages

Lecture

Lecture

37 pages

Lecture

Lecture

36 pages

lecture

lecture

46 pages

Lecture

Lecture

33 pages

Lecture

Lecture

57 pages

Lecture

Lecture

32 pages

Lecture

Lecture

46 pages

Lecture

Lecture

40 pages

Lecture

Lecture

11 pages

Lecture

Lecture

6 pages

Lecture

Lecture

43 pages

Lecture

Lecture

12 pages

Lecture

Lecture

18 pages

Exam

Exam

10 pages

Lecture

Lecture

45 pages

Lecture

Lecture

37 pages

Exam

Exam

24 pages

class09

class09

21 pages

class22

class22

37 pages

class20

class20

30 pages

class27

class27

33 pages

class25

class25

21 pages

class04

class04

31 pages

Lecture

Lecture

59 pages

class01a

class01a

14 pages

class12

class12

45 pages

class29

class29

33 pages

Lecture

Lecture

39 pages

Lecture

Lecture

6 pages

class03

class03

34 pages

lecture

lecture

42 pages

Lecture

Lecture

40 pages

Lecture

Lecture

47 pages

Exam

Exam

19 pages

R06-B

R06-B

25 pages

class17

class17

37 pages

class25

class25

31 pages

Lecture

Lecture

15 pages

final-f06

final-f06

17 pages

Lecture

Lecture

9 pages

lecture

lecture

9 pages

Exam

Exam

15 pages

Lecture

Lecture

22 pages

class11

class11

45 pages

lecture

lecture

50 pages

Linking

Linking

37 pages

Lecture

Lecture

64 pages

Integers

Integers

40 pages

Exam

Exam

11 pages

Lecture

Lecture

37 pages

Lecture

Lecture

44 pages

Lecture

Lecture

37 pages

Lecture

Lecture

9 pages

Lecture

Lecture

37 pages

Lecture

Lecture

45 pages

Final

Final

25 pages

lecture

lecture

9 pages

Lecture

Lecture

30 pages

Lecture

Lecture

16 pages

Final

Final

17 pages

Lecture

Lecture

8 pages

Exam

Exam

11 pages

Lecture

Lecture

47 pages

Lecture

Lecture

9 pages

lecture

lecture

39 pages

Exam

Exam

11 pages

lecture

lecture

41 pages

lecture

lecture

37 pages

Lecture

Lecture

59 pages

Lecture

Lecture

45 pages

Exam 1

Exam 1

18 pages

Lecture

Lecture

41 pages

Lecture

Lecture

32 pages

Lecture

Lecture

30 pages

Lecture

Lecture

9 pages

Lecture

Lecture

9 pages

Lecture

Lecture

15 pages

Lecture

Lecture

11 pages

Lecture

Lecture

9 pages

Lecture

Lecture

34 pages

Lecture

Lecture

40 pages

Lecture

Lecture

4 pages

Lecture

Lecture

46 pages

Lecture

Lecture

8 pages

Lecture

Lecture

65 pages

Lecture

Lecture

38 pages

Lecture

Lecture

35 pages

Lecture

Lecture

8 pages

Lecture

Lecture

34 pages

Lecture

Lecture

8 pages

Exam

Exam

13 pages

Lecture

Lecture

43 pages

Lecture

Lecture

9 pages

Lecture

Lecture

12 pages

Lecture

Lecture

9 pages

Lecture

Lecture

34 pages

Lecture

Lecture

43 pages

Lecture

Lecture

7 pages

Lecture

Lecture

45 pages

Lecture

Lecture

24 pages

Lecture

Lecture

47 pages

Lecture

Lecture

12 pages

Lecture

Lecture

20 pages

Lecture

Lecture

9 pages

Exam

Exam

11 pages

Lecture

Lecture

52 pages

Lecture

Lecture

20 pages

Exam

Exam

11 pages

Lecture

Lecture

35 pages

Lecture

Lecture

47 pages

Lecture

Lecture

18 pages

Lecture

Lecture

30 pages

Lecture

Lecture

59 pages

Lecture

Lecture

37 pages

Lecture

Lecture

22 pages

Lecture

Lecture

35 pages

Exam

Exam

23 pages

Lecture

Lecture

9 pages

Lecture

Lecture

22 pages

class12

class12

32 pages

Lecture

Lecture

8 pages

Lecture

Lecture

39 pages

Lecture

Lecture

44 pages

Lecture

Lecture

38 pages

Lecture

Lecture

69 pages

Lecture

Lecture

41 pages

Lecture

Lecture

12 pages

Lecture

Lecture

52 pages

Lecture

Lecture

59 pages

Lecture

Lecture

39 pages

Lecture

Lecture

83 pages

Lecture

Lecture

59 pages

class01b

class01b

17 pages

Exam

Exam

21 pages

class07

class07

47 pages

Lecture

Lecture

11 pages

Odyssey

Odyssey

18 pages

multicore

multicore

66 pages

Lecture

Lecture

6 pages

lecture

lecture

41 pages

lecture

lecture

55 pages

lecture

lecture

52 pages

lecture

lecture

33 pages

lecture

lecture

46 pages

lecture

lecture

55 pages

lecture

lecture

17 pages

lecture

lecture

49 pages

Exam

Exam

17 pages

lecture

lecture

56 pages

Exam 2

Exam 2

16 pages

Exam 2

Exam 2

16 pages

Notes

Notes

37 pages

Lecture

Lecture

40 pages

Lecture

Lecture

36 pages

Lecture

Lecture

43 pages

Lecture

Lecture

25 pages

Exam

Exam

13 pages

Lecture

Lecture

32 pages

Lecture

Lecture

12 pages

Lecture

Lecture

58 pages

Lecture

Lecture

29 pages

Lecture

Lecture

59 pages

Lecture

Lecture

41 pages

Lecture

Lecture

50 pages

Exam

Exam

17 pages

Lecture

Lecture

29 pages

Lecture

Lecture

44 pages

Lecture

Lecture

41 pages

Lecture

Lecture

52 pages

Lecture

Lecture

40 pages

Lecture

Lecture

33 pages

lecture

lecture

10 pages

Lecture

Lecture

27 pages

Lecture

Lecture

29 pages

Lecture

Lecture

39 pages

Lecture

Lecture

9 pages

Lecture

Lecture

29 pages

Lecture

Lecture

8 pages

Lecture

Lecture

43 pages

Lecture

Lecture

43 pages

Lecture

Lecture

75 pages

Lecture

Lecture

55 pages

Lecture

Lecture

43 pages

Lecture

Lecture

35 pages

lecture

lecture

36 pages

Exam

Exam

33 pages

lecture

lecture

56 pages

lecture

lecture

64 pages

lecture

lecture

8 pages

Exam

Exam

14 pages

Lecture

Lecture

43 pages

Lecture

Lecture

36 pages

lecture

lecture

56 pages

lecture

lecture

75 pages

lecture

lecture

36 pages

Lecture

Lecture

50 pages

Lecture

Lecture

45 pages

Lecture

Lecture

13 pages

Exam

Exam

23 pages

Lecture

Lecture

10 pages

Lecture

Lecture

48 pages

Lecture

Lecture

83 pages

lecture

lecture

57 pages

Lecture

Lecture

33 pages

Lecture

Lecture

39 pages

Lecture

Lecture

33 pages

lecture

lecture

54 pages

Lecture

Lecture

30 pages

Exam

Exam

13 pages

Lecture

Lecture

36 pages

Lecture

Lecture

40 pages

Exam

Exam

17 pages

Lecture

Lecture

9 pages

Exam

Exam

15 pages

Lecture

Lecture

44 pages

Lecture

Lecture

34 pages

Lecture

Lecture

24 pages

Lecture

Lecture

29 pages

class12

class12

43 pages

lecture

lecture

43 pages

class22

class22

22 pages

R06-B

R06-B

25 pages

class01b

class01b

19 pages

lecture

lecture

29 pages

lab1

lab1

8 pages

Caches

Caches

36 pages

lecture

lecture

55 pages

Lecture,

Lecture,

37 pages

Integers

Integers

40 pages

Linking

Linking

38 pages

lecture

lecture

45 pages

Lecture

Lecture

61 pages

Linking

Linking

33 pages

lecture

lecture

40 pages

lecture

lecture

40 pages

Lecture

Lecture

32 pages

lecture

lecture

48 pages

lecture

lecture

44 pages

Exam

Exam

11 pages

Lecture

Lecture

31 pages

Lecture

Lecture

46 pages

Lecture

Lecture

40 pages

Lecture

Lecture

40 pages

Exam

Exam

12 pages

Lecture

Lecture

42 pages

Lecture

Lecture

36 pages

Lecture

Lecture

45 pages

Lecture

Lecture

41 pages

Lecture

Lecture

13 pages

Lecture

Lecture

35 pages

Lecture

Lecture

20 pages

Final

Final

19 pages

Lecture

Lecture

33 pages

Lecture

Lecture

50 pages

Lecture

Lecture

33 pages

Lecture

Lecture

27 pages

Lecture

Lecture

6 pages

Exam

Exam

15 pages

Lecture

Lecture

24 pages

Lecture

Lecture

23 pages

Lecture

Lecture

43 pages

Lecture

Lecture

32 pages

Lecture

Lecture

52 pages

Lecture

Lecture

37 pages

Lecture

Lecture

36 pages

Lecture

Lecture

34 pages

Lecture

Lecture

40 pages

Lecture

Lecture

15 pages

lecture

lecture

21 pages

Lecture

Lecture

58 pages

Lecture

Lecture

49 pages

Lecture

Lecture

36 pages

Lecture

Lecture

11 pages

Lecture

Lecture

12 pages

Lecture

Lecture

58 pages

Lecture

Lecture

33 pages

Exam

Exam

15 pages

Lecture

Lecture

35 pages

Lecture

Lecture

10 pages

Lecture

Lecture

25 pages

Lecture

Lecture

31 pages

Lecture

Lecture

24 pages

Lecture

Lecture

34 pages

Lecture

Lecture

50 pages

lecture

lecture

35 pages

Lecture

Lecture

11 pages

Lecture

Lecture

39 pages

Lecture

Lecture

45 pages

Lecture

Lecture

41 pages

exam1-f05

exam1-f05

11 pages

Lecture

Lecture

4 pages

Lecture

Lecture

17 pages

Exam

Exam

17 pages

malloc()

malloc()

12 pages

Lecture

Lecture

57 pages

Lecture

Lecture

30 pages

Lecture

Lecture

30 pages

Lecture

Lecture

47 pages

Lecture

Lecture

33 pages

Exam

Exam

12 pages

Lecture

Lecture

43 pages

Lectures

Lectures

33 pages

Lecture

Lecture

36 pages

lecture

lecture

33 pages

Exam

Exam

14 pages

Lecture

Lecture

43 pages

Lecture

Lecture

25 pages

Load more
Download Exam
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Exam and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Exam and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?