המצגת נטענת. אנא המתן

המצגת נטענת. אנא המתן

הכנה למבחן.

מצגות קשורות


מצגת בנושא: "הכנה למבחן."— תמליל מצגת:

1 הכנה למבחן

2 סינכרוניזציה

3 Question Q.5b – midterm 2010 Consider the following simple algorithm similar to that shown in class: Is this algorithm deadlock free? Prove or disprove by providing an accurate scenario which leads to a deadlock. 1 int lock initially 0 2 boolean interested[n] initially {false,…,false} Code for procss i{0,…,n-1} 3 interested[i]:=true 4 await ((test-and-set(lock)=0) OR (interested[i] =false)) 5 Critical Section 6 j:=(i+1) modulo n 7 while (j ≠ i) AND (interested[j] = false) j:=(j+1) modulo n 9 if (j=i) 10 lock:=0 11 else 12 interested[j]:=false 13 interested[i]=false Test-and-set(w) do atomically prev:=w w:=1 return prev

4 Answer Q.5b The following scenario results in a deadlock:
A process p0 is executed and executes all lines up until the beginning of line 13. (Note that ‘lock’ is freed) Another process p1 is executed and allowed to run all the way through the CS. At this point p1 iterates through the other processes and identifies that ‘interested[0]=true’. As a result p1 resets the value ‘interested[0]:=false’ (line 12) and does not free the lock. It then proceeds to line 13 and exits. p0 runs line 13. At this point the system is in a state of deadlock. Any process attempting to enter the CS will be stopped by line 4. Reductio ad absurdum

5 The one-way tunnel problem
Allows any number of processes in the same direction If there is traffic in the opposite direction – have to wait A special case of readers/writers

6 The one way tunnel (exam 2004)
The one way tunnel solution: int count[2]; Semaphore busy=1, mutex=1; Semaphore waiting[2]={1,1}; void arrive(int direction){ down(&waiting[direction]); down(&mutex); count[direction]+=1; if (count[direction]==1){ up(&mutex); down(&busy); } else up(&waiting[direction]); } void leave(int direction){ down(&mutex); count[direction]-=1; if (count[direction]==0){ up(&busy); } up(&mutex);

7 The one way tunnel (exam 2004)
Add changes to the one way tunnel solution so that there will be no starvation. If vehicles are present on both “0” and “1” they will take alternate turns in entering the tunnel. When there are vehicles coming from only one direction, they can pass through with no limitations. Notes: you may only use integers and binary semaphores (can assume fairness).

8 The one way tunnel (exam 2004)
int count[2]; Semaphore busy = 1, mutex = 1, new_mutex = 1; Semaphore waiting[2] = {1,1}; void arrive(int direction) { down(&waiting[direction]); down(&new_mutex); down(&mutex); count[direction] += 1; if(count[direction] == 1) { up(&mutex); down(&busy); { else up(&mutex); up(&new_mutex); up(&waiting[direction]); } void leave(int direction){ down(&mutex); count[direction]-=1; if (count[direction]==0){ up(&busy); } up(&mutex);

9 One way, convoy (midterm 2008)
In the following question you must implement a solution to the convoy problem using only semaphores (and regular variables). In this problem, each thread represent a vehicle. The vehicles must go through a one way tunnel, but unlike the tunnel problem, here vehicles may only cross the tunnel in groups of exactly 5 (all in the same direction). A group of another 5 vehicles (from the same or opposite direction) may cross the tunnel again, only after the previous group of 5 vehicles comes out of it. The general code structure is as follows: Variable Declaration PrepareToCross(int direction) CROSS DoneWithCrossing(int direction)

10 One way, convoy (midterm 2008)
Implement PrepareToCross() and DoneWithCrossing(). For your implementation you may only use semaphores (counting or binary) and regular variables. No busy-waiting is allowed. We say a thread is passing the tunnel if it completed its call to PrepareToCross and haven’t called DoneWithCrossing or if it is still in PrepareToCross but is no longer waiting on a semaphore, and when it will receive CPU time it may complete the procedure without waiting. Your implementation must satisfy the following conditions: Mutual Exclusion – threads from different direction may never be in the tunnel at the same time. Threads may only cross in groups of 5. When the first is leaving PrepareToCross, there are exactly 4 others which are passing the tunnel as well. Progress – Whenever there are 5 (or more) threads from the same direction waiting to cross the tunnel, then eventually, 5 will.

11 One way, convoy (midterm 2008)
We will use the following: Counting Semaphore waitingToCross[]={5,5} Counting Semaphore barrier[]={0,0} Binary Semaphore busy=1 Binary Semaphore mutex=1 int waitingCount[]={0,0} int passed=0

12 One way, convoy (midterm 2008)
PrepareToCross(int i){ down(&waitingToCross[i]); down(&mutex); waitingCount[i]++; If (waitingCount[i]<5){ up(&mutex); down(&barrier[i]); } else { waitingCount[i]=0; down(&busy); for (int k=0; k<4; k++) up(&barrier[i]); } up(&waitingToCross[i]); DoneWithCrossing(int i){ down(&mutex); passed++; if (passed==5){ passed=0; up(&busy); } up(&mutex);

13 Java and monitors – Exercise
Write a code snippet in Java which will enforce a FIFO waking order (i.e., create a class in Java that will allow a programmer fair synchronization)

14 Java and monitors – Solution
class SafeMonitor { boolean released = false; // this flag avoids race!!! synchronized void await() throws InterruptedException { while (! released) { wait(); } } synchronized void signal(){ if (! released){ released = true; notify(); } } }

15 Java and monitors – Solution
class CriticalSection { private List<SafeMonitor> waiting; private boolean busy; public CriticalSection() { waiting = new LinkedList<>(); busy = false; } public void enter() { SafeMonitor myLock = null; synchronized(this) { if (! busy) { busy = true; return; } else { myLock = new SafeMonitor(); waiting.add(myLock); } } myLock.await(); } public synchronized void leave() { if (!waiting.isEmpty()) { waiting.remove().signal(); } else { busy = false; }

16 Java and monitors – Solution
class CriticalSection { private List<SafeMonitor> waiting; private boolean busy; public CriticalSection() { waiting = new LinkedList<>(); busy = false; } public void enter() { SafeMonitor myLock = null; synchronized(this) { if (! busy) { busy = true; return; } else { myLock = new SafeMonitor(); waiting.add(myLock); } } myLock.await(); } public synchronized void leave() { if (!waiting.isEmpty()) { waiting.remove().signal(); } else { busy = false; } Does this code guarantee a FIFO waking order which is equivalent to the order in which threads reached the critical section entrance? What happens when multiple threads attempt to enter at the same time?

17 ניהול זיכרון

18 Question 1 Assume a 32 bit system, with 2-level page table (page size is 4KB, |p1|=|p2|=10bits, |offset|=12bits). Program “A” on this system requires 12 MB of memory. The bottom 4MB of memory are used by the program text segment, followed by 4MB for data and lastly, the top 4MB for stack. How many page table pages are actually required for this process. Describe the lookup within the page tables of address 0x The 12 least significant digits in this address, allow access for 212 bytes – 4 KB. These are pointed to by any of the 210 entries of p2. In total, a second level page table can point to 222 bytes – 4 MB. 0x = 1(dec) = 3(dec) = 4(dec)

19 Question 1 We use the following scheme:
The 12 least significant digits in this address, allow access for 212 bytes – 4 KB. These are pointed to by any of the 210 entries of p2. In total, a second level page table can point to 222 bytes – 4 MB. Each such page table is pointed to by a first level table entry. In our case – we require 4 page table pages: a single first level page table (also known as the “directory”), which points to 3 second level page tables. page offset p1 p2 d 10 12

20 Question 1 1023 1 2 3 4 Top-level page table 1023 4095 page offset page number p1 p2 d 4 4 10 10 12 3 3 2 2 1 1 32 bit virtual address, 4K pages, lookup of 0x (4,206,596(dec)) Binary: = 1(dec) = 3(dec) = 4(dec) 4 – 8 MB 12288 – Byte

21 Question 2 Consider a paged memory system with a two-level page table. If the reference time to access the physical memory takes 20 nanoseconds (ns), how long does a paged memory reference take? Assume that the second-level page table is always in memory, and: There is no TLB, and the needed page is in main memory. There is a TLB, with access speed of 0.05 ns, the needed page is in main memory and The TLB does not contain information on this page. The TLB contains information on this page.

22 Question 2 We will need to access the memory three times: in the first and second accesses we will get the first and second level page table entry. This will point us to the physical address we will access next. Total time: 3x20 = 60ns. Remember we first access the TLB: Since this entry is not located in the TLB, after examining it, we will revert to the regular lookup scheme (as before). Total time: x20 = 60.05ns. If the entry is in the TLB, after examining it we will know the location of the exact page frame and access it directly. Total time: = 20.05ns. Note that the use of virtual memory may significantly reduce memory performance. The TLB provides a mechanism to overcome this problem.

23 Question 3 Consider a computer with an address space of 32 bits, and a 2KB page size. What is the size of the page table (single level)? What is the maximal size of a program’s memory? Does it depends on the size of the pages? Assume a two level page table, in which 8 bits are dedicated for the first level table. What is the size of the 2nd table (per first level entry)? Can we run larger programs now? Assume that the first level table is always in memory and a page fault occurs with a 4% chance when attempting to access the pages it points to. When retrieving pages pointed to by the second level table a PF occurs in 1% of the attempts. Calculate the average access time to a page, if disk access time is 30x10-6sec, and memory access time is 100x10-9sec. The virtual memory size is 232 bytes, size of each page is 2KB (211 bytes). Total number of pages is therefore 232/211=221 pages. Since each address is 4 bytes long (32 bit machine), we require 4x221 = 223 bytes = 8 MB to hold this table.

24 Question 3 The virtual memory size is 232 bytes, and the size of each page is 2KB (211 bytes). Total number of pages is therefore 232/211=221 pages. Since each address is 4 bytes long (32 bit machine), we require 4x221 = 223 bytes = 8 MB to hold this table. Maximal program size is 4 GB (size of virtual memory), regardless of the page size.

25 Question 3 Using 8 bits for the first level page table, leaves us with 13 bits for the second level page table. The size of the second table is 4x213 = 32KB. The size of the virtual memory stays the same, and we can’t run bigger programs.

26 Question 4 What is the size of a single level page table on a 32 bit machine, with 4KB pages? What is the size of a 64 bit machine’s page table with 4KB pages? How many layers will we need if we want to ensure that each page table entry will require only a single page?

27 Question 4 If the address space consists of 232 bytes, with 4KB pages, we have 232/212=220 entries (over 1 million). Using 4 bytes per entry, we get a 4MB page table. With a 64 bit machine, we need 252 entries. Each entry being 8 bytes long results in a 32 PetaBytes (Peta > Tera > Giga) page table. Limiting page table parts to fit the size of a page means that we can only use 212/23=29 addresses in each table segment. This corresponds to 52/9≈6 levels in this page table. That is, the memory is accessed 6 times to retrieve each virtual address.

28 Question 5.2 The time required to read an entry from the TLB in a given system is 10 nsec. Access time to a single level page table entry is 10 times slower, and requires 100 nsec. What should be the TLB hit rate so that the average time to find a virtual address will be 30 nsec? Explain your calculation

29 Question 5.2 The TLB hit rate provides a measure of successful TLB hits when seeking a virtual address. When a successful TLB hit occurs the virtual address is translated directly from the TLB. In contrast, when the page is not in the TLB one has to access the page table. Let p denote the TLB hit rate. We know that: p∙10 + (1-p) ∙(10+100) = 30 Thus, the TLB hit rate should be: p=0.8 Note: with a high TLB hit rate memory access time is 70% faster!

30 קבצים

31 Question 1: i-nodes How many time will the disk be accessed when a user executes the following command: more /usr/tmp/a.txt Assume that: The size of 'a.txt' is 1 block. The i-node of the root directory is not in the memory. Entries 'usr', 'tmp' and 'a.txt' are all located in the first block of their directories. Ignore the disk access required in order to load more

32 Question 1: answer Accessing each directory requires at least 2 disk accesses: reading the i-node and the first block. In our case the entry we are looking for is always in the first block so we need exactly 2 disk accesses. According to assumption 2 the root directory's  i-node is located on the disk so we need 6 disk accesses (3 directories) until we reach a.txt's i-node index. Since "more" displays the file's content, for a.txt we need its i-node + all the blocks of the file (1 block, according to assumption). Total disk accesses: = 8.

33 Question 2: i-nodes The Ofer2000 Operating Systems, based on UNIX, provides the following system call: rename(char *old, char *new) This call changes a file’s name from ‘old’ to ‘new’. What is the difference between using this call, and just copying ‘old’ to a new file, ‘new’, followed by deleting ‘old’? Answer in terms of disk access and allocation.

34 Question 2: i-nodes rename - simply changes the file name in the entry of  its directory. copy -  will allocate a new i-node and the blocks for the new file, and copy the contents of the old file blocks to the new ones. delete - will release the i-node and blocks of the old file. copy + delete - is a much more complicated operation for the Operating System, note that you will not be able to execute it if you do not have enough free blocks or i-nodes left on your disk.

35 Question 3: i-nodes What would be the maximal size of a file in a UNIX system with an address size of 32 bits if : The block size is 1K The block size is 4K The i-node has 10 direct block entries, single, double & triple indirect

36 Question 3: i-nodes Block size: 1K Direct: 10·1K
Single indirect: each address is 32 bit = 4 byte then we have 256 pointers to blocks of size 1K (i.e. 256·1K) The same idea is applied for double and triple indirect. In total: 10·1K+256·1K+256·256·1K+256·256·256·1K ~= 16G

37 Question 3: i-nodes Block size: 4K Direct: 10·4K
Single indirect: each address is 32 bit = 4 byte then we have 1024 pointers to blocks of size 4K (i.e. 1024·4K) The same idea is applied for double and triple indirect In total: 10·4K+1024·4K+1024·1024·4K+1024·1024·1024·4K ~= 4T

38 וירטואליזציה

39 Question (Moed B 2017) במערכת וירטואלית ישנו hypervisor התומך בshadow page tables. תאר בקצרה תהליך חיפוש כתובת וירטואלית במערכת מה היתרון של מערכת כזו על פני מערכת המשתמשת ב brute force?

40 Question (Moed B 2017) Guest OS Hypervisor TLB CPU HW G-CR3 CR3
Page table VMM SW Shadow page table Page dir. Interrupt & VMM corrects page table. G-CR3 TLB CPU CR3 HW

41 Question (Moed B 2017) במערכת כזו ישנו רגיסטר בCPU המצביע על הShadow page table. בהינתן כתובת וירטואלית של לקוח במערכת כזו ישנן 2 אופציות: טבלאות הshadow ממפות את הכתובת והתהליך זהה למערכת רגילה הטבלאות shadow אינן ממפות את הכתובת, יתקבל interrupt מסוג page fault שיעביר אותנו לקוד בhypervisor אשר יבדוק האם הכתובת ממופה בטבלאות הלקוח (ע"י משתנה שישמור את כתובת הטבלה הראשית של הלקוח), אם הכתובת לא ממופה נחזיר page fault ללקוח, אחרת נמפה את הדף בטבלאות הshadow כדי שימפה ישירות לזכרון המערכת ונחזור למערכת האורחת (כעת חזרנו למקרה (1)

42 Question (Moed B 2017) Guest OS Hypervisor TLB CPU HW CR3
Define these pages as not R/W Guest OS Hypervisor Page table VMM SW VM memory layout Page dir. TLB CPU CR3 HW

43 Question (Moed B 2017) במערכת המבצעת גישות brute force סימנו את כל דפי המיפוי כnon read non write ולכן על כל גישה יתקבל interrupt. במערכת מסוג shadow page table נקבל interrupt רק על הגישה הראשונה לדף כלשהו, מהרגע שמיפינו אותו המערכת האורחת יכולה להמשיך לעבוד כרגיל

44 מועד א' 2018

45 תהליכים, חוטים ומערכות קבצים (25 נקודות).
בשאלה זו 5 סעיפים. בסעיפים א-ג נתון כי תוכן הקובץfile.txt הוא ”abcd”. עבור כל אחד מסעיפים אלו ,יש לכתוב במחברת את הפלט של התוכנית הנתונה. אם יוחזר קוד שגיאה כתוצאה מאחת ה-system calls, יש לציין זאת (יש להניח שקיימות הרשאות מתאימות לפתוח את הקובץ ולפיכך הוא ייפתח בהצלחה). נמקו בקצרה.

46 תודפס המחרוזת ”ab” ואחריה המחרוזת ”cd”
תודפס המחרוזת ”ab” ואחריה המחרוזת ”cd”. תהליכים אב ובן חולקים file position משותף של קובץ שנפתח לפני ה- fork.

47 תודפס המחרוזת ”ab” ואחריה המחרוזת ”ab”
תודפס המחרוזת ”ab” ואחריה המחרוזת ”ab”. שני התהליכים פותחים את הקובץ לאחר ה- fork ולפיכך אינם חולקים את ה- file position.

48 תודפס המחרוזת ”ab” (ע"י החוט הבן) ואחריה, כאשר החוט האב ינסה לקרוא, הקריאה תחזיר error code בשל הניסיון של החוט האב לקרוא מן הקובץ לאחר שהחוט הבן כבר סגר אותו. יחד עם זה, הריצה תמשיך ואז גם החוט האב ידפיס ”ab” משום שהוא מדפיס ממשתנים c1, c2 (המשותפים עם החוט הבן) אליהם כבר נכתבו הערכים ‘a’ ו- ‘b’.

49 ד. (5 נק') במערכת קבצים של UNIX, נמחק בשל תקלה תוכן הקובץ של הספריה /usr/ast/work. ספריה זו אינה מכילה תתי-ספריות, אלא רק 100 קבצים רגילים. נניח שידועים מספרי ה- inodes של הקבצים בספריה. בנוסף, נניח שלכל קובץ בספריה בוצע לפני התקלהsoftlink מקובץ שאינו בספריה. ענו במחברת על השאלות הבאות ונמקו בקצרה: האם ניתן לשחזר את הרשימה של שמות כל הקבצים בספריה? האם בהינתן שם של קובץ כלשהו בספריה, ניתן לשייך לו את מספר ה- inode המתאים באופן ודאי? ניתן לשחזר את שמות הקבצים משום שה- path של קובץ היעד נשמר כאשר יוצרים אליו softlink (כתוכנו של קובץ ה- softlink). לפיכך ניתן לסרוק את עץ המחיצות ולמצוא softlinks אליו. לא ניתן לשייך לשמות את ה- inodes בתיקייה שנמחקה, משום שה-softlink אינו שומר את ה- target inode.

50 ה. (5נק') בהמשך לסעיף ד, נניח שבמקום softlink, לכל קובץ בספריה בוצע לפני התקלה hardlink מקובץ שאינו בספריה. ענו שוב על שתי השאלות, כלומר: האם ניתן לשחזר את הרשימה של שמות כל הקבצים בספריה? האם בהינתן שם של קובץ כלשהו בספריה, ניתן לשייך לו את מספר ה- inode המתאים באופן ודאי? לא ניתן לשחזר לא את שמות הקבצים ולא את ה inodes משום שאין דרך לדעת אילו באילו כניסות של מחיצות אחרות יש hardlinks לקבצים בתיקייה שנמחקה.

51 2. סינכרוניזציה - בעיית המניעה ההדדית (25 נקודות)
בכל הסעיפים בשאלה זו, על מנת להוכיח שתכונה אינה מתקיימת, יש לכתוב תסריט מדויק המדגים זאת. על מנת להוכיח שתכונה מתקיימת, יש לכתוב נימוק קצר ומדויק (אין צורך בהוכחות פורמליות). א. (10 נק') הפעולה האטומית test-and-set מופעלת על משתנה משותף, כותבת אליו 1 ומחזירה את ערכו הקודם (ראו פסאודו-קוד להלן).

52 להלן אלגוריתם פשוט למניעה הדדית המשתמש בפעולה זו:
ענו על השאלות הבאות: האם האלגוריתם מקיים חופש מקיפאון (deadlock freedom)? האם האלגוריתם מקיים חופש מהרעבה (starvation freedom)? נניח כי משנים את האתחול של משתנה v בשורה 1 ל- 1. מהן התשובות לסעיפים i ו- ii כעת? כן. כאשר אין תהליך בקטע הקריטי ערכו של v הוא 0 ולכן תתכן עוד כניסה. לא. יתכן שתהליך מסוים נכשל שוב ושוב בפעולת test-and-set בגלל שתהליכים אחרים מצליחים שוב ושוב. כעת יתכן גם deadlock משום שכאשר v מאותחל ל- 1 שום פעולת test-and-set אינה יכולה להצליח.

53 האם האלגוריתם מקיים חופש מקיפאון?
האם האלגוריתם מקיים חופש מהרעבה? נניח כי משנים את האלגוריתם ע"י העברת שורה 5 (h[i]:=false) לסוף קטע היציאה, אחרי שורה 13. מהן התשובות לסעיפים i ו- ii כעת?

54 תשובות: מקיים. כאשר תהליך יוצא, או שהוא מעביר לתהליך אחר את המנעול בשורה 10 או שהוא משחרר את המנעול בשורה 13. לפיכך תמיד תיתכן עוד כניסה. לא, בגלל שהסריקה בלולאה 7 מתחילה החל מ – j=0, יתכן התסריט הבא: תהליך 1 בקטע הקריטי, תהליכים 2 ו-3 ממתינים בשורה 3 תהליך 1 יוצא ומכניס את תהליך 2 בשורה 10 תהליך 1 מנסה להיכנס שוב ונכנס להמתנה בשורה 3 תהליך 2 יוצא ומכניס את תהליך 1 בשורה 10 ניתן להמשיך תסריט זה שוב ושוב בעוד תהליך 3 סובל מהרעבה. כעת יתכן גם deadlock (מובן שגם starvation), להלן תסריט: תהליך 1 נכנס לקטע הקריטי תהליך 2 ממתין בשורה 3 תהליך 1מכניס את תהליך 2 בשורה 10 אבל עוצר לפני שהוא כותבh[1]=false בשורה האחרונה תהליך 2 יוצא, כותב h[1]=false ולא משחרר את המנעול תהליך 1 כותב h[1]=false ויוצא, מעכשיו המנעול תפוס לנצח - deadlock.

55 3. ניהול זיכרון (25 נקודות) א. (9 נק') במערכת הפעלה יש זיכרון פיזי ובו 3 דפים (page frames) ואילו הזיכרון הוירטואלי של כל תהליך במערכת הוא בגודל של 5 דפים. החל ממצב בו הזיכרון הפיזי ריק, מתבצעת סדרת הגישות הבאה (משמאל לימין): 1, 2, 3, 1, 4, 1, 5, 2. עבור כל אחד מן האלגוריתמים הבאים, כתבו מה מספר ה- page faults שייגרם כתוצאה מסדרת הגישות. פרטו את חישוביכם כך שניתן יהיה לבדוק כיצד הגעתם לתשובה. FIFO: סה"כ 7 page faults. השורה העליונה מתארת page faults והתחתונה את הדף שמוצא מהזיכרון. 1, 2, 3, 1, 4, 1, 5, 2 x, x, x, x, 1, 2, 3, 4 LRU: סה"כ 6 page faults. x, x, x, x, 2, x, 3, 4 Optimal page replacement: סה"כ 5 page faults. x, x, x, x, 3, x, 1, x

56 ב. (8 נק’) במערכת מחשב התומכת ב- paging יש מרחב זיכרון וירטואלי של 38 ביט. נתון כי גודלו של כל דף במערכת הוא 16K bytes, יש בה טבלת דפים בת שתי רמות (two level page table), הטבלה ברמה הראשונה תופסת דף יחיד וגודלו של כל page table entry הוא 4 bytes. כמה ביטים מן הכתובת הוירטואלית צריכים להיות מוקצים לטבלה ברמה הראשונה וכמה צריכים להיות מוקצים לטבלה ברמה השנייה? פרטו את חישוביכם כך שניתן יהיה לבדוק כיצד הגעתם לתשובה. מספר הכניסות בטבלה ברמה הראשונה (בסקלה לוגריתמית) הוא 12=14-2, כלומר מוקצים לה 12 ביטים מהכתובת. גודל דף בסקלה לוגריתמית הוא 14 ביטים שמתורגמים כמו שהם. לכן עבור הטבלה ברמה שניה נשארים 12= ביטים.

57 ג. (8 נק') נניח כי מגדילים את גודלו של כל דף וירטואלי במערכת התומכת ב- paging. עבור כל אחת מן הטענות הבאות, כתבו במחברת האם היא נכונה או לא. נמקו במילים ספורות. כמות הזיכרון המוקצית לטבלת הדפים תקטן. נכון. ישנם פחות דפים למפות. הסיכוי ל- TLB hit יגדל. נכון. המידע שניגשים אליו בזמן ריצה צפוי לשבת בפחות ולפיכך מרחב הכתובות הוירטואליות הממופה ע"י הכניסות של ה- TLB גדל. זמן הטיפול ב- page fault יקטן. לא נכון. סביר שיגדל כיוון שיש להעתיק יותר מידע מהדיסק לזיכרון בעת הטיפול ב- page fault. הפרגמנטציה הפנימית (internal fragmentation) של מנגנון ה- paging תגדל. נכון. גודל יחידת ההקצאה המינימלית עולה ולכן יהיה בזבוז יותר גדול של זיכרון עבור בקשות הקצאה קטנות.

58 4. מערכת Xv6 (12 נקודות) יש לענות בקצרה ובמדויק על הסעיפים הבאים. א. (12 נק') את הפונקציה namex של Xv6, שהקוד שלה מוצג בדף האחרון של הבחינה, אתם אמורים להכיר מעבודה מספר 4. ענו בקצרה על השאלות הבאות: מה תפקידה של פונציה זו? בפרט, מה מייצג הפרמטר path ומה מייצג הערך המוחזר ע"י הפונקציה? (בתשובתכם, ניתן להתעלם מן הפרמטרים השני והשלישי שהפונקציה מקבלת). בהינתן כתובת path, הפונקציה מחפשת ומחזירה את ה- inode המתאים ל path. הערך החוזר הוא מספר ה- inode אם ה- path נמצא, אחרת 0. מה מבצעת שורה 5762 ובאילו מקרים היא נקראת? אם מבוצע חיפוש של relative path, שורה זו משכפלת למשתנה ip את ה-inode של ה- current working directory של התהליך על מנת שהחיפוש יתחיל ממנו. מה תפקידה של הפונקציה dirlookup הנקראת בשורה 5775? בפרט, מה מייצגים שני הפרמטרים הראשונים שהיא מקבלת והערך אותו היא מחזירה? פונקציה זו מחפשת במחיצה המוצבעת ע"י ip קובץ בשםname. אם קובץ בשם זה נמצא במחיצה מוחזר מצביע ל- inode שלו, אחרת מוחזר 0.

59


הורד את "ppt "הכנה למבחן.

מצגות קשורות


מודעות Google