OS PyramidTechnion 234123 · Operating Systemsbasics → exam
Stage 10: Storage & Filesystems
winter_2019-2020_examAQuestion 1corecritical25 pts

מעתה (ביתר השאלה) נתייחס למערך inode.arr השונה במעט מהמוצג למעלה בכך שסדר הפוינטרים שבו הוא: inode.arr[0] is a triple indirect pointer, inode.arr[1] is a double indirect pointer, inode.arr[2] is an indirect pointer, inode.arr[3..14] are direct pointers, כך שחיפוש בלוק שמתאים להיסט בקובץ (file offset) מתבצע כרגיל: היסט 0 מופיע במקום ה- 0 של הרמה התחתונה ביותר שבעץ תחת הפוינטר [0]inode.arr . הניחו כי הסופר-בלוק של מערכת הקבצים נמצא בזיכרון ושאר הנתונים (קבצים, inodes, וכו') אינם בזיכרון. כפי שנלמד בתרגול, כל inode במערכת הקבצים שומר את זמן הגישה האחרונה לקובץ (atime). נתון הקוד הבא: int fd = open("/X/", O_RDONLY); read(fd, buf, 8192);

Full original question text (raw OCR)

במערכת קבצים כלשהי, שדומה למערכת הקבצים הקלאסית של Unix, השדה arr ב- inode מכיל מערך של מצביעים: inode.arr[0..11] are direct pointers, inode.arr[12] is an indirect pointer, inode.arr[13] is a double indirect pointer, inode.arr[14] is a triple indirect pointer. הניחו שה-inode של מערכת הקבצים הינו בגודל 512B (תמיד aligned על כפולה של 512B). כמו כן, הניחו שמערכת הקבצים מורכבת (mounted) על דיסק בגודל 1TB בעל גודל בלוק של 8KB.

  1. 1· short_answer· 4 ptsStorage & Filesystems

    (4 נק') נסמן ב- N את מספר המצביעים שבלוק מסוג indirect יכול להכיל. מהו ערך ה- N המקסימלי?

    libc syscall wrapper caching pitfallsHard link vs symlink inode behaviorSRT / preemptive Gantt construction
  2. 2· calculation· 4 ptsStorage & Filesystems

    (4 נק') מה הגודל המקסימלי של קובץ במערכת הקבצים הנ"ל כפונקציה של N? (מדובר על גודל הנתונים, ללא מטה-נתונים (meta-data). נדרש ביטוי פשוט ככל האפשר.)

    libc syscall wrapper caching pitfalls
    review:T2·22
  3. 3· calculation· 4 ptsStorage & Filesystems

    (4 נק') מהו תחום ההיסטים בקובץ שנגישים דרך [13]node.arr ?? (על התשובה להיות "מ- K עד P", בבתים. הביטוי יכול להיות תלוי ב-N שהוגדר לעיל.)

    SRT / preemptive Gantt construction
  4. 4· short_answer· 3 ptsStorage & Filesystems

    (3 נק') נתון קובץ בגודל 16KB. בכמה בלוקים בדיסק קיימים מטה-נתונים אודות הקובץ?

    libc syscall wrapper caching pitfallsHard link vs symlink inode behaviorSRT / preemptive Gantt construction
  5. (3 נק') בהשוואה ל-inode.arr מתחילת השאלה, האם תשתנה ההשהייה (latency) בקריאה מקובץ בגודל ?16KB הקיפו: תגדל / תקטן / תישאר ללא שינוי

    Latency vs throughput process classificationHard link vs symlink inode behaviorSRT / preemptive Gantt construction
  6. 6· trace· 4 ptsStorage & Filesystems

    (4 נק') מה מספר הגישות לדיסק בעת ביצוע open? תארו את רצף הגישות בטבלה (כמו בתרגול).

    libc syscall wrapper caching pitfallsHard link vs symlink inode behaviorSRT / preemptive Gantt construction
  7. 7· trace· 3 ptsStorage & Filesystems

    (3 נק') מה מספר הגישות לדיסק בעת ביצוע read? תארו את רצף הגישות בטבלה (כמו בתרגול).

    libc syscall wrapper caching pitfallsHard link vs symlink inode behaviorSRT / preemptive Gantt construction

The exam question — original PDF

pages 2, 3, 4

Exactly as it appears on the exam paper.

loading page 2
loading page 3
loading page 4

Built from these components

Ordered basic → advanced. Master the earlier ones first.

L2System call trap and kernel entryL2Latency vs throughput process classificationL3libc syscall wrapper caching pitfallsL3Per-process file descriptor tableL3Hard link vs symlink inode behaviorL4SRT / preemptive Gantt construction

Review the material

Read these before you answer — each verified slide teaches a component this question tests, and nothing from an unrelated topic is included. Tutorial slides show the actual slide image.

Lecture 4–5slide 39SRTF (Shortest-Remaining-Time First)

SRTF (Shortest-Remaining-Time First) • Assume different jobs may arrive at different times • SJF is not optimal – As it’s not preemptive, and – A short job might arrive while a very long job is running => recall: convoy effect • SRTF is just like SJF but – Is allowed to use preemption – Hence, it’s “optimal” (assuming a zero context-switch cost etc.) • Whenever a new job arrives, or an old job terminates – SRTF schedules the job with the shortest remaining time – Thereby making an optimal decision 39 OS (234123) - scheduling

Lecture slide — text above is the material (no raster available).
Lecture 11–12slide 9POSIX file descriptors (FDs)

POSIX file descriptors (FDs) • A successful open<“file name”> of a file returns a FD rpt – A nonnegative integer – An index to a per-process array called the “file descriptor table” – Each entry in the array saves, e.g., the current offset – Threads share the array (and hence the offset) – C’s FILE structure encapsulates a FD • FD or filename? – Some file-related POSIX system calls operate on FDs • read, write, fchmod, fchown, fchdir, fstat, ftruncate… – Others operate on file names • chmod, chown, chdir, stat, truncate – Has security implications: FD versions are more secure in some sense • Because association of FD to underlying file is immutable – Once an FD exists, it will always point to the same file • Whereas association between file & its name is mutable – So they can lead to TOCTTOU (time of check to time of use) races OS (234123) - files 9

Lecture slide — text above is the material (no raster available).
Lecture 11–12slide 26Hard links – when is a file deleted?

Hard links – when is a file deleted? • Every file has a “reference count” associated with it – link()  ref_count++ – unlink()  ref_count-- • if( ref_count == 0 ) – The file has no more names – It isn’t pointed to from any node within the file hierarchy – So it can finally be deleted • What if an open file is deleted? (its ref_count==0) – Can we still access the file through the open FD(s)? • Yes – If >=1 processes have the file open when the last link is removed • The link shall be removed before unlink() returns • But the removal of the file contents shall be postponed until all references (file descriptors) to the file are close()-ed • Have you seen files names that begin with “.nfs”? OS (234123) - files 26

Lecture slide — text above is the material (no raster available).
Lecture 11–12slide 34inodes & *stat syscalls

inodes & *stat syscalls • lstat(2) – Exactly the same as stat(2) if applied to a hard link – But if applied to a symlink, would return the information of this symlink (not to the target of the symlink) – In this case, POSIX says that the only fields within the stat structure that you can portably use are: • st_mode which will specify that the file is a symlink • st_size symlink content length (= length of target filepath) – The value of the rest of the fields could be valid, but it is not specified by POSIX – Notably, it is not specified if a symlink has a corresponding inode • Will be discussed shortly OS (234123) - files 34

Lecture slide — text above is the material (no raster available).
Tutorial 2slide 16קריאת המערכת waitpid()pid_t waitpid(pid_t pid, int *wstatus, int options);פעולה: המתנה לסיום בן ספציפי שמספרו pid

קריאת המערכת waitpid()pid_t waitpid(pid_t pid, int *wstatus, int options);פעולה: המתנה לסיום בן ספציפי שמספרו pid.wait(), waitpid() הן קריאות מערכת חוסמות.כלומר חוסמות את התקדמות התהליך עד להתרחשות תנאי מסוים.באנגלית: blocking system calls.הארגומנט options מאפשר לשנות את ההתנהגות של waitpid() לקריאת מערכת לא חוסמת.אם options==WNOHANG קריאת המערכת תחזור מיד, כאשר ערך חזרה 0 משמעותו שאף תהליך בן עוד לא סיים, ואילו ערך חזרה חיובי הוא ה-pid של תהליך בן שסיים ונמצא עדיין במצב zombie.מערכות הפעלה - תרגול 216

Tutorial 2slide 22קריאות המערכת getpid(), getppid()pid_t getpid();קריאת מערכת המחזירה לתהליך הקורא את ה-pid של עצמו

קריאות המערכת getpid(), getppid()pid_t getpid();קריאת מערכת המחזירה לתהליך הקורא את ה-pid של עצמו.pid_t getppid();קריאת מערכת המחזירה את ה-PID של תהליך האב של התהליך הקורא.שאלה: מה המשמעות של getppid() == 1 עבור תהליך משתמש טיפוסי?תשובה: תהליך האב הוא init. קורה למשל אם תהליך הבן יתום.מערכות הפעלה - תרגול 222

Tutorial 2slide 25אתחול תהליכים בלינוקסמשתמשים מתחברים לעבודה בלינוקס דרך מסופים (terminal)

אתחול תהליכים בלינוקסמשתמשים מתחברים לעבודה בלינוקס דרך מסופים (terminal).מסוף = מסך + מקלדת (מקומי או מרוחק).התהליך init יוצר תהליך בן עבור כל מסוף, אשר טוען ומבצע את המשימות הבאות לפי הסדר:איתחול של המסוף.התחברות של המשתמש עם שם משתמש וסיסמא באמצעות תכנית login.אם אושרה כניסת המשתמש: קריאה לתוכנית shell(כמו tcsh או bash) המאפשרת למשתמש להעביר פקודות למערכת ההפעלה.מערכות הפעלה - תרגול 225

Tutorial 2slide 26דוגמה לשימוש בתהליכים - shellממשק שורת פקודה (command line)

דוגמה לשימוש בתהליכים - shellממשק שורת פקודה (command line).ייעוד עיקרי: לקבל פקודות ולבצע אותן באופן סדרתי.ה-shell מייצר תהליך בן עבור כל פקודה על-מנת לבצע אותה.כל פקודה ניתן להריץ בחזית (foreground) או ברקע (background).הרצה בחזית: האב (shell) ממתין לסיום הבן לפני קריאת הפקודה הבאה.הרצה ברקע: האב (shell) עובר מיד לקריאת הפקודה הבאה.ייעוד נוסף: להציג קבצים ותיקיות על-מנת לסייר במערכת.דוגמה חיה:https://www.tutorialspoint.com/unix_terminal_online.phpמערכות הפעלה - תרגול 226

Tutorial 5slide 9דוגמת FCFSaverageResponseTime = (10 + 20 + 30) / 3 = 20כעת נסיר את הנחה 1 ("כל התהליכים רצים למשך אותו זמן")

דוגמת FCFSaverageResponseTime = (10 + 20 + 30) / 3 = 20כעת נסיר את הנחה 1 ("כל התהליכים רצים למשך אותו זמן"). לכל תהליך זמן ריצה משלו.תוכלו לחשוב על דוגמה שבה FCFS אינו יעיל?מערכות הפעלה - תרגול 59כל התהליכים רצים למשך אותו זמן.כל התהליכים מגיעים באותו זמן (t=0).אם תהליך התחיל לרוץ, אז הוא ירוץ עד לסיומו ללא הפסקות.התהליכים משתמשים רק במעבד ולא מבצעים I/O.זמן הריצה של כל התהליכים ידוע מראש.

Tutorial 5slide 10אפקט השיירה (convoy effect)averageResponseTime = (100 + 110 + 120) / 3 = 110אלגוריתם FCFS עלול לסבול מ"אפקט השיירה": ...

אפקט השיירה (convoy effect)averageResponseTime = (100 + 110 + 120) / 3 = 110אלגוריתם FCFS עלול לסבול מ"אפקט השיירה": מצב שבו תהליך אחד ארוך מעכב הרבה תהליכים קצרים. מערכות הפעלה - תרגול 510

Tutorial 5slide 23נהוג לסווג תהליכים לשני סוגיםתהליך אינטראקטיבי I/O Boundמעוניין בזמן המתנה נמוך

נהוג לסווג תהליכים לשני סוגיםתהליך אינטראקטיבי I/O Boundמעוניין בזמן המתנה נמוך.latency sensitive.דוגמה: נגן סרטים שמחליף 60 פריימים בשנייה.בדרך-כלל מוותר על המעבד מרצונו אחרי פרק זמן קצר בגלל המתנה לפעולות I/O.תהליך חישוביCPU Boundמעוניין בזמן תגובה נמוך.throughput sensitive.דוגמה: סקריפט python שמנתח נתונים ע"י חישובים אלגבריים.בדרך-כלל לא מוותר על המעבד מרצונו אלא מופקע.מערכות הפעלה - תרגול 523

Tutorial 12slide 4הבעיה: התקני איחסון איטייםהתקני איחסון הם בעלי השהיה גבוהה יחסית לזיכרון

הבעיה: התקני איחסון איטייםהתקני איחסון הם בעלי השהיה גבוהה יחסית לזיכרון.זמני ההשהיה האופיינים (נכון לשנת 2020) בגישה אקראית*:זיכרון (DRAM) – 100 ns.כונן SSD – 16 us.כונן דיסק קשיח (HDD) – 2 ms.המרכיב הדומיננטי הוא זמן הזזת הראש הקורא (seek latency).*גישה אקראית מוגדרת כקריאה/כתיבה של 8B בכתובת כלשהי.מערכות הפעלה - תרגול 124

Tutorial 13slide 13בלינוקס יש שני סוגי קישורים (links)soft / symbolic linkln -s src dstקישור סימבולי הוא קובץ חדש עם inode נפרד מזה של ה...

בלינוקס יש שני סוגי קישורים (links)soft / symbolic linkln -s src dstקישור סימבולי הוא קובץ חדש עם inode נפרד מזה של הקובץ המקורי.כתיבה דרך הקישור כותבת לקובץ אליו הוא מצביע.מחיקת הקישור (באמצעות הפקודה rm) לא תמחק את הקובץ המוצבע.אפשר ליצור קישורים סימבוליים גם לקובץ שלא קיים.hard linkln src dstקישור קשיח הוא שם נרדף לקובץ המקורי כי הוא מצביע ישירות ל-inode של הקובץ המקורי.כתיבה דרך הקישור כותבת לקובץ אליו הוא מצביע.מחיקת הקישור תקטין את מונה הקישורים של הקובץ (כפי שנשמר ב-inode).הקובץ יימחק מהדיסק רק כאשר כל ה-hard links אליו יימחקו.מערכות הפעלה - תרגול 1213

Tutorial 13slide 19>> rm /A/helloמערכות הפעלה - תרגול 1219inode #2type=dirdatanameinode #A5B7inode #5type=dirdatanameinode #…………inode #1...

>> rm /A/helloמערכות הפעלה - תרגול 1219inode #2type=dirdatanameinode #A5B7inode #5type=dirdatanameinode #…………inode #13type=soft_linkdatainode #7type=dirdatanameinode #soft13……data block/A/helloקישור "שבור"!dangling link

Ask Gemini
winter_2019-2020_examA · Q1 — question + its material already loaded
Pick a shortcut above or ask anything about this question.
The exam text, the skills it tests, and the exact slides are already in context.