Full original question text (raw OCR)
בשאלה זו, נדון במערכת קבצים FAT. נתון שגודל בלוק הוא 4KB, והוא שווה לגודל דף (Page) ושווה לגודל מסגרת (Frame). המערכת מותקנת על דיסק בנפח y*4KB, כלומר בדיסק יש y בלוקים. נתון ש-y הוא חזקה שלמה של 2.
מה הוא מספר הכניסות בטבלת ה-File Allocation Table (ה-FAT)? בטאו את תשובתכם בעזרת y.
libc syscall wrapper caching pitfallsPer-process file descriptor tableHard link vs symlink inode behaviorכמה ביטים נדרש לכל כניסה בטבלת ה-File Allocation Table (ה-FAT)? בטאו את תשובתכם בעזרת y.
libc syscall wrapper caching pitfallsPer-process file descriptor tableHard link vs symlink inode behaviorבהנחה שלא מעגלים למעלה (כלפי החזקה השלמה הקרובה של 2) את גודל הכניסה בטבלת ה-FAT, מה יהיה גודל הטבלה (בבתים)? בטאו את תשובתכם בעזרת y.
libc syscall wrapper caching pitfallsPer-process file descriptor tableHard link vs symlink inode behaviorמיכאל, מהנדס מחשבים בחברת Fandisk, נדרש לתכנן מערכת קבצים לדיסק-און-קי החדש של החברה. המנהל של מיכאל דרש ניצולת של לפחות 99.9% במערכת. כלומר, החלק של הדיסק השמור לנתוני הקבצים והתיקיות (Data Region) צריך להיות לפחות 99.9% מנפח הדיסק הכולל. מיכאל בחר להשתמש במערכת FAT. מהו נפח הדיסק המקסימלי האפשרי (בבתים) תחת דרישה זו במערכת FAT? ניתן להתעלם מה-superblock בחישובים שלכם. תזכורת: מספר הבלוקים הכולל y צריך להיות חזקה שלמה של 2.
libc syscall wrapper caching pitfallsמרים, שותפה של מיכאל לפרויקט, הציעה את השינוי הבא למערכת הקבצים FAT: בכל כניסה בטבלת ה-FAT, נשמור 2 מצביעים: אחד לבלוק הבא, והשני לבלוק הבא אחריו. כלומר בכל כניסה בטבלת ה-FAT, נשמור מצביעים ל-2 הבלוקים העוקבים לבלוק הנוכחי. תארו יתרון אחד להצעה של מרים.
libc syscall wrapper caching pitfallsבהנחה שמיישמים את ההצעה של מרים, כיצד תשתנה תשובתכם לסעיף 3? כלומר, מה יהיה נפח הדיסק המקסימלי האפשרי (בבתים) תחת דרישת ניצולת מינימלית של 99.9% במערכת FAT עם ההצעה של מרים? ניתן להתעלם מה-superblock בחישובים שלכם. תזכורת: מספר הבלוקים הכולל y צריך להיות חזקה שלמה של 2.
libc syscall wrapper caching pitfallsהסבירו את המושג קישורים קשיחים (Hard links). האם מערכת הקבצים FAT תומכת בריבוי של קישורים קשיחים לאותו קובץ? נמקו.
libc syscall wrapper caching pitfallsHard link vs symlink inode behavior
The exam question — original PDF
pages 2, 3Exactly as it appears on the exam paper.
Built from these components
Ordered basic → advanced. Master the earlier ones first.
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.
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
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
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
קריאת המערכת 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
קריאת המערכת exit()שאלה: למה בכלל לקרוא ל-exit(status) , אם אפשר פשוט לרשום return status בסוף פונקציית ה-main?תשובה: main היא לא באמת הפונקציה הראשית של התכנית...main() נקראת ע"י __libc_start_main() שאוספת את ערך החזרה של main() וקוראת ל-exit().int __libc_start_main(…) { …… exit(main(…));}מסקנה: הפונקציה exit תמיד נקראת לסיום סטנדרטי של התוכנית.מערכות הפעלה - תרגול 218
קריאות המערכת getpid(), getppid()pid_t getpid();קריאת מערכת המחזירה לתהליך הקורא את ה-pid של עצמו.pid_t getppid();קריאת מערכת המחזירה את ה-PID של תהליך האב של התהליך הקורא.שאלה: מה המשמעות של getppid() == 1 עבור תהליך משתמש טיפוסי?תשובה: תהליך האב הוא init. קורה למשל אם תהליך הבן יתום.מערכות הפעלה - תרגול 222
דוגמת קודמסכמתprintf("pid = %d\n", getpid());pid_t pid = fork();if (pid == 0) { printf("child pid = %d\n", getpid()); char* args[] = {"/bin/date", NULL}; execv(args[0], args); printf("This should not be printed\n");} else { wait(NULL); printf("parent pid = %d\n", getpid());}פלט לדוגמה:pid = 8919child pid = 8920Sun Oct 29 00:31:32 IDT 2017parent pid = 8919מערכות הפעלה - תרגול 224
אתחול תהליכים בלינוקסמשתמשים מתחברים לעבודה בלינוקס דרך מסופים (terminal).מסוף = מסך + מקלדת (מקומי או מרוחק).התהליך init יוצר תהליך בן עבור כל מסוף, אשר טוען ומבצע את המשימות הבאות לפי הסדר:איתחול של המסוף.התחברות של המשתמש עם שם משתמש וסיסמא באמצעות תכנית login.אם אושרה כניסת המשתמש: קריאה לתוכנית shell(כמו tcsh או bash) המאפשרת למשתמש להעביר פקודות למערכת ההפעלה.מערכות הפעלה - תרגול 225
דוגמה לשימוש בתהליכים - shellממשק שורת פקודה (command line).ייעוד עיקרי: לקבל פקודות ולבצע אותן באופן סדרתי.ה-shell מייצר תהליך בן עבור כל פקודה על-מנת לבצע אותה.כל פקודה ניתן להריץ בחזית (foreground) או ברקע (background).הרצה בחזית: האב (shell) ממתין לסיום הבן לפני קריאת הפקודה הבאה.הרצה ברקע: האב (shell) עובר מיד לקריאת הפקודה הבאה.ייעוד נוסף: להציג קבצים ותיקיות על-מנת לסייר במערכת.דוגמה חיה:https://www.tutorialspoint.com/unix_terminal_online.phpמערכות הפעלה - תרגול 226
בלינוקס יש שני סוגי קישורים (links)soft / symbolic linkln -s src dstקישור סימבולי הוא קובץ חדש עם inode נפרד מזה של הקובץ המקורי.כתיבה דרך הקישור כותבת לקובץ אליו הוא מצביע.מחיקת הקישור (באמצעות הפקודה rm) לא תמחק את הקובץ המוצבע.אפשר ליצור קישורים סימבוליים גם לקובץ שלא קיים.hard linkln src dstקישור קשיח הוא שם נרדף לקובץ המקורי כי הוא מצביע ישירות ל-inode של הקובץ המקורי.כתיבה דרך הקישור כותבת לקובץ אליו הוא מצביע.מחיקת הקישור תקטין את מונה הקישורים של הקובץ (כפי שנשמר ב-inode).הקובץ יימחק מהדיסק רק כאשר כל ה-hard links אליו יימחקו.מערכות הפעלה - תרגול 1213
>> rm /A/helloמערכות הפעלה - תרגול 1219inode #2type=dirdatanameinode #A5B7inode #5type=dirdatanameinode #…………inode #13type=soft_linkdatainode #7type=dirdatanameinode #soft13……data block/A/helloקישור "שבור"!dangling link
The exam text, the skills it tests, and the exact slides are already in context.