Operating Systems, 142. Practical Session 12 File Systems, part 2

Similar documents
ASP.Net MVC + Entity Framework Code First.

תצוגת LCD חיבור התצוגה לבקר. (Liquid Crystal Display) המערכת.

Advisor Copy. Welcome the NCSYers to your session. Feel free to try a quick icebreaker to learn their names.

טכנולוגיית WPF מספקת למפתחים מודל תכנות מאוחד לחוויית בניית יישומיי

A R E Y O U R E A L L Y A W A K E?

DNS פרק 4 ג' ברק גונן מבוסס על ספר הלימוד "רשתות מחשבים" עומר רוזנבוים 1

אנגלית (MODULE E) בהצלחה!

Hebrew Ulpan HEB Young Judaea Year Course in Israel American Jewish University College Initiative

Practical Session No. 13 Amortized Analysis, Union/Find

פרק 2- תכנות. socketים ברק גונן מבוסס על ספר הלימוד "רשתות מחשבים" עומר רוזנבוים 1

מבוא למחשב בשפת פייתון

1.1. הקדמה (דיסק). מדריכי. (מחיצות) Link

FILED: NEW YORK COUNTY CLERK 07/16/2014 INDEX NO /2014 NYSCEF DOC. NO. 134 RECEIVED NYSCEF: 07/16/2014 EXHIBIT 37

SEEDS OF GREATNESS MINING THROUGH THE STORY OF MOSHE S CHILDHOOD

מכונת מצבים סופית תרגול מס' 4. Moshe Malka & Ben lee Volk

אנגלית שאלון ז' ג רסה א' הוראות לנבחן בהצלחה! )4( ההנחיות בשאלון זה מנוסחות בלשון זכר ומכוונות לנבחנות ולנבחנים כאחד. (MODULE G)

ניפוי שגיאות )Debug( מאת ישראל אברמוביץ

תכנית סטארט עמותת יכולות, בשיתוף משרד החינוך א נ ג ל י ת שאלון ב' Corresponds with Module B גרסה ב' הוראות לנבחן

ANNEXURE "E1-1" FORM OF IRREVOCABLE STANDBY LETTER OF CREDIT PERFORMANCE OF CONTRACT (WHERE PRICES ARE NOT LINKED TO AN ESCALATION FORMULA)

שאלון ו' הוראות לנבחן

אוניברסיטת בן-גוריון בנגב, המחלקה למדעי המחשב

THINKING ABOUT REST THE ORIGIN OF SHABBOS

Genetic Tests for Partners of CF patients

שאלון ד' הוראות לנבחן

שאלון ו' הוראות לנבחן

א נ ג ל י ת בהצלחה! ב. משרד החינוך בגרות לנבחנים אקסטרניים )מילון הראפס אנגלי-אנגלי-ערבי( השימוש במילון אחר טעון אישור הפיקוח על הוראת האנגלית.

המחלקה למדעי המחשב, אוניברסיטת בן גוריון מבני נתונים, סמסטר אביב 2102 עבודת בית מספר - 2 מעשית

תכנית סטארט עמותת יכולות, בשיתוף משרד החינוך א נ ג ל י ת שאלון א' Corresponds with Module A (Without Access to Information from Spoken Texts) גרסה א'

אנגלית שאלון ז' (MODULE G) ג רסה א' הוראות לנבחן )מילון אנגלי-ערבי / ערבי-אנגלי )

זו מערכת ישרת זוית )קרטזית( אשר בה יש לנו 2 צירים מאונכים זה לזה. באותו מישור ניתן להגדיר נקודה על ידי זוית ורדיוס וקטור

מספר השאלון: Thinking Skills נספח: כישורי חשיבה )לפרק ראשון ושני( א נ ג ל י ת (MODULE F) ספרות )מילון הראפס אנגלי-אנגלי-ערבי(

Hebrew Adjectives. Hebrew Adjectives fall into 3 categories: Attributive Predicative Substantive

Name Page 1 of 6. דף ט: This week s bechina starts at the two dots in the middle of

Reflection Session: Sustainability and Me

A JEW WALKS INTO A BAR: JEWISH IDENTITY IN NOT SUCH JEWISH PLACES

נספח: כישורי חשיבה )לפרק ראשון ושני( אנגלית (MODULE F) ספרות או: מילון אנגלי-ערבי / ערבי-אנגלי או: מילון אנגלי-אנגלי-ערבי

פרוטוקול HTTP הפונקציה header שליחת מידע דחוס. עבודה עם cookies Haim Michael. All Rights Reserved.

NTFS ADS Magic Tricks

eriktology The Writings Book of Ecclesiastes [1]

נספח: כישורי חשיבה )לפרק ראשון ושני( אנגלית (MODULE D) ספרות מילון אנגלי-אנגלי-עברי או מילון אנגלי-עברי-עברי-אנגלי

נספח: כישורי חשיבה )לפרק ראשון ושני( אנגלית (MODULE F) ספרות מילון אנגלי-אנגלי-עברי או מילון אנגלי-עברי-עברי-אנגלי

(MODULE E) ב ה צ ל ח ה!

Rules Game (through lesson 30) by Nancy Decker Preparation: 1. Each rule board is immediately followed by at least three cards containing examples of

קשירות.s,t V שני צמתים,G=(V,E) קלט: גרף מכוון מ- s t ל- t ; אחרת.0 אם יש מסלול מכוון פלט: הערה: הגרף נתון בייצוג של רשימות סמיכות.

P2P Content Distribution BitTorrent and Spotify

מספר ת"ז: יש לסמן את התשובה הטובה ביותר בתשובון. לא יינתן ניקוד על סימון תשובה בטופס הבחינה או במחברת הבחינה.

תורשכ ירפס לכ ץבוק " ב י קלח יללכ רעש

נספח: כישורי חשיבה )לפרק ראשון ושני( אנגלית (MODULE D) ספרות או מילון אנגלי-עברי-עברי-אנגלי

JUDAISM AND INDIVIDUALITY

FILED: NEW YORK COUNTY CLERK 07/16/2014 INDEX NO /2014 NYSCEF DOC. NO. 102 RECEIVED NYSCEF: 07/16/2014 EXHIBIT 5

ב. משרד החינוך בגרות לנבחנים אקסטרניים א נ ג ל י ת (MODULE B) הוראות מיוחדות: )2( בתום הבחינה החזר את השאלון למשגיח. בהצלחה!

אנגלית ספרות בהצלחה! /המשך מעבר לדף/ נספח: כישורי חשיבה )לפרק ראשון ושני( או: מילון אנגלי-ערבי / ערבי-אנגלי או: מילון אנגלי-אנגלי-ערבי

Translation Practice (Review) Adjectives Pronouns Pronominal suffixes Construct chains Bible memory passages

Patents Basics. Yehuda Binder. (For copies contact:

מדריך למשתמש התקנה עצמית

HEBREW THROUGH MOVEMENT

בהצלחה! (MODULE C) Hoffman, Y. (2014). The Universal English-Hebrew, Hebrew-English Dictionary

תוכן העניינים: פרק סדרות סיכום תכונות הסדרה החשבונית:... 2 תשובות סופיות:...8 סיכום תכונות הסדרה ההנדסית:...10

נספח: כישורי חשיבה )לפרק ראשון ושני( אנגלית (MODULE D) ספרות או מילון אנגלי-עברי-עברי-אנגלי

המבנה הגאומטרי של מידה

מספר השאלון: הצעת תשובות לשאלות בחינת הבגרות אנגלית (MODULE C) מילון אנגלי-אנגלי-עברי או מילון אנגלי-עברי-עברי-אנגלי قاموس إنجليزي - إنجليزي - عربي

NATIONAL COUNCIL OF YOUNG ISRAEL. Shavuot Nation JEWISH EDITION. Compiled by Gabi Weinberg Teen Program Director

ãówh,é ËÓÉÔê ÌW W É Å t" Y w f É ËÓÉÑ É èw É f Ñ u ð NNM YóQ' ÌW W É Y ÉgO d óqk É w f ym Éd É u ð NNM ÌWNQMH uqo ð NNM ÌWNQMH

מדריך לניהול VPS טריפל סי מחשוב ענן בע"מ.

Name Page 1 of 5. דף ז. This week s bechina begins with the fifth wide line at the top of

ב. משרד החינוך בגרות לנבחנים אקסטרניים א נ ג ל י ת (MODULE B) הוראות מיוחדות: )2( בתום הבחינה החזר את השאלון למשגיח. בהצלחה!

מבוא לאסמבלי מאת אופיר בק חלקים נרחבים ממאמר זה נכתבו בהשראת הספר "ארגון המחשב ושפת סף" אשר נכתב ע"י ברק גונן לתוכנית גבהים של משרד החינוך.

sharing food intro price & extra drinks * ניתן להזמין מנות כשרות בתאום מראש for good memories

לצפייה בפתרון בווידאו לתרגילים שבחוברת, כנסו ל "סטטיסטיקה והסתברות" בשאלון 802 שבאתר

שאלות חזרה לקראת מבחן מפמ"ר אינטרנט וסייבר

הקדמה בדיקת תמיכה ב- SSL מאת עידו קנר

FULL ARTICLE ACTIVE DIRECTORY

eriktology Torah Workbook Bereshiyt / Genesis [1]

interface Student {tag: Student, name: string; age: number;} const makestudent = ( name: string, age: number ) : Student =>

Visual C# Express Edition 2005

תרגול 8. Hash Tables

יסודות מבני נתונים. תרגול :9 ערימה - Heap

T H E S U N F L O W E R L I M I T S T O F O R G I V E N E S S

קריאת גרפים. לצפייה בפתרון בווידאו לתרגילים שבחוברת, כנסו ל "קריאת גרפים" בשאלון 801 שבאתר 116

Interrogatives. Interrogative pronouns and adverbs are words that are used to introduce questions. They are not inflected for gender or number.

מדריך למשתמש בשירות. yes MultiRoom

The Art of Rebuke. Source #1: Story of Kamtzah and Bar Kamtzah Talmud Gittin 55b-56a

Parashat Balak. Sharon Rimon

מבחן באנגלית בהצלחה הצלחה!!! שם פרטי: שם משפחה: מס' תעודת זהות: תאריך: שם מרכז מנהל מרכז השכלה: תאריך בדיקת המבחן: כל הזכויות שמורות למשרד החינוך

Relationships: Everything Else is Commentary

הצעת תשובות לשאלות בחינת הבגרות אנגלית

ראש השנה דף. 1. A) Our משנה says,... שנראה בעליל בין שלא נראה בעליל.בין Based on this,פסוק what does the word עליל mean?

ב "ה. ABC s of Judaism. Fundamentals of Jewish Thought and Practice. June 2007 Tammuz 5767 Jewish Educational Institute Chabad Brisbane

HEBREW THROUGH MOVEMENT

A lot of the time when people think about Shabbat they focus very heavily on the things they CAN T do.

עץ תורשה מוגדר כך:שורש או שורש ושני בנים שכל אחד מהם עץ תורשה,כך שערך השורש גדול או שווה לסכום הנכדים(נכד-הוא רק בן של בן) נתון העץ הבא:

חוק זכויות הסוכן חוק חוזה סוכנות )סוכן מסחרי וספק(

Adam: Meet Haman. A Sermon Delivered by Rabbi Haskel Lookstein on Shabbat Bereishit October 25, 2008

A Long Line for a Shorter Wait at the Supermarket

ASTM UL / FM / BS abesco

דגשים: הערות: John Bryce Linux Forum: (Linux) BIND Mini How-To (In Hebrew) על שרת Red Hat Enterprise Linux גרסא.5.

Structural Vs. Nominal Typing

Computer Structure. Exercise #1 יש להגיש את התשובות הסופיות על גבי טופס זה.

And now Israel, what does Hashem your G-d ask from you but to revere Hashem your G-d

BEING A VISIONARY JOLT LEADERSHIP PROGRAM 2014

Transcription:

Operating Systems, 142 Practical Session 12 File Systems, part 2 1

File system layout (Tanenbaum) 2

Quick recap: i-nodes An i-node (index node) is a data structure containing pointers to the disk blocks that contain the actual file contents. Every i-node object represents a single file. An i-node needs to be in Main Memory only if the correspondent file is open. 3

Quick recap: FAT A FAT (File allocation table) contains the chains of disk blocks. Each chain defines a different file. Every entry in the FAT points to the next disk block of the file. Chains of blocks are terminated by a special marker end_of_file character. Directory entry points to first block in a file (i.e. specifies the block number). The FAT is held in Main Memory and its size is proportional to the disk size.

Recap: MS-DOS directory entry Tree structure (no links) directories provide information about location of file blocks (directly or indirectly..) Both names and attributes are IN the directory read-only hidden system archive An index into the 64K entry FAT MS-DOS uses fixed size 32-byte directory entries 5

NTFS Each file is represented by a record in a special file called the master file table (MFT). Directories are also files. The first 16 records of the table are reserved for special information and the first record of this table describes the master file table itself, followed by a MFT mirror record. The seventeenth and following records of the master file table are for user files and directories. The master file table allocates a certain amount of space for each file record (for attributes and initial data). Small files can be entirely contained within the master file table record in this case file access is very fast.

MFT records

The MFT record of a long file A file that requires three MFT records to store its runs Ben-Gurion University Operating Systems, Semester B 2008, Danny Hendler 8

NFS Network File System Allows sharing of file Systems. A server exports part of its file system. A client can mount an exported file system. A stateless protocol. The server remembers nothing about previous requests from a client.

Design compare Allocation method File representation Location of filename Location of attributes Data access Location of index table EXT4 NTFS 6 FAT32 Indexed Indexed, by runs Linked i-node (default size 256KB) Directory entry MFT record (default size 1Kb) Directory entry, MFT record Chain of clusters pointed from a Directory entry Directory entry i-node MFT record Directory entry i-node contain pointers with different levels of indirection i-nodes table immediately after the superblock For small files- the contents inside the MFT record, for largerorganized as 'runs' which may span multiple MFT records MFT anywhere, pointed by MBR Directory entry Points to 1 st link in chain FAT anywhere, pointed by MBR 10

Features compare EXT4 NTFS 6 FAT32 Built in security Yes Yes No Recoverability Efficient disk usage Fragmentation problem Max file size Max volume size Max filename length Yes, via data and metadata journaling Yes, via sparse files No 16TB (for 4k block) 1EB (1EB=1,000,000TB) 255 chars (case sensitive) Yes, via metadata journaling Yes, via compression, sparse files Some, tries to store files sequentially 16EB by design, 16TB by implementation 16EB 255 chars (case sensitive) No No Yes 4GB 2TB Originally 8+3, extended to 255 (not case sensitive) Hard links Yes Yes No Soft links Yes Yes No 11

Pros & Cons Pros Cons EXT4 NTFS 6 FAT32 Supports large volumes and files Built in security and permissions Recoverability Unicode file names Extended file attributes No fragmentation problems, no maintenance needed Small memory footprint Compatibility issues with other OS Larger disk footprint than NTFS Modern Supports large volumes and files Built in security and permissions Recoverability Unicode file names Extended file attributes High performance on large directories and files Fragmentation problem Inefficient on small volumes Performance degrades when disk is almost full Size of MFT grows with usage Simple Widely supported Efficient for small files on small volumes and sequential access Obsolete Not suitable for large volumes and files No recoverability No security No user permissions Fragmentation 12 reduce performance

Question 1: FAT A FAT starts with the following values: Assuming that slots with -1 indicates an end of file and slots with 0 indicates a free slot: 1. If the directory containing a certain file has 7 as the starting block, how many blocks does that file contain? 2. The owner of the file has written two more blocks to the file. Adjust the FAT to the change.

Question 1: FAT 1. 4 2. 14, 19, 8, -1, -1, 9, 3, 2, 5, 10, -1 0 X 1 X 2 EOF 3 13 4 2 5 9 6 8 7 Free 8 Y 9 12 10 3 11 FREE 12 EOF 13 EOF 14 FREE 15 BAD Not allocated End of file Marked as a bad block File A: File B: File C: 6 8 4 2 5 9 12 10 3 13

Question 2: FAT (2007a) בשאלה זו עליכם להציע שינויים )במבני הנתונים ובקוד( של מערכת הקבצים של MS-DOS על מנת להוסיף לה תמיכה ב- links. לאחר השינוי, תתמוך MS-DOS בשתי הפקודות החדשות הבאות: אל.old-path הפקודה: soft-link old-path new-path יוצרת soft link חדש מ- new-path הפקודה: hard-link old-path new-path יוצרת hard link חדש מ- new-path אל.old-path

Question 2: FAT (2007a) )13 נקודות( אנו רוצים להוסיף למערכת הקבצים של MS-DOS תמיכה ב- links, soft מבלי לבצע שינוי כלשהוא בטבלת ה- FAT ומבלי להוסיף מבני נתונים חדשים. א. תארו בפירוט אילו מבני נתונים של MS-DOS ישתנו וכיצד. (a השינוי היחיד הנדרש הינו תוספת flag ב- entry,directory המציין האם הקובץ המוצבע ע"י ה- entry הינו symbolic link או לא. במידה וה- flag מורם, תוכנו של הקובץ ששמו מופיע ב- entry הינו ה- link )כלומר,.)old-path

Question 2: FAT (2007a) b) כתבו פסאודו-קוד המתאר את פעולתה של פרוצדורה soft-link(old-path, new-path) המממשת את הפקודה. soft-link Procedure soft-link(old-path, new-path) } // get directory-name and entry-name Convert new-path to <dirname, entryname> // allocate a new directory entry in directory dirname new-entry allocate-new-entry(dirname) new-entry.filename entryname new-entry.link true // indicate that this is a symbolic link allocate a single block, initialize with old-path, set it as new-entry's single block new-entry.data old-path {

Question 2: FAT (2007a) האם נדרשים שינויים נוספים בקוד של?MS-DOS אם כן, ציינו אותם בקצרה. )c כאשר מבצעים parsing ל- pathname עוברים על ה- directories שבו )אם ישנם כאלה( על פי הסדר, החל מן ה root directory או ה- directory current )בתלות אם זהו absolute או.)relative path עבור כל שם name בו נתקלים, יש לבדוק אם הוא מיצג,link ע"י בדיקת ה- flag שהוספנו. אם כן, יש לקרוא את תוכן הקובץ name למשתנה,link להחליף את name ב- link, ולהמשיך את פעולת ה- parsing החל מתחילת.link המימוש שלנו בסעיף b. מרשה הצבעות של link ל- link. יש למנוע לולאה אינסופית במהלך פעולת ה- parsing, למשל ע"י ספירה של מספר הפעמים בהן התהליך נתקל ב- link ויציאה עם הודעת שגיאה מתאימה במידה והמונה מגיע לערך סף שנקבע מראש. אפשרות נוספת היא למנוע מראש הצבעות בין לינקים. ל- false. link כאשר יוצרים קובץ רגיל, יש לאתחל את דגל

Question 2: FAT (2007a) ב. )12 נקודות( כעת נוסיף למערכת הקבצים של MS-DOS תמיכה ב- links,hard מבלי לבצע שינוי כלשהוא בטבלת ה- FAT )הניחו כי ניתן להיעזר במבני נתונים נוספים(. a( תארו בפירוט אילו מבני נתונים של MS-DOS ישתנו וכיצד, ואילו מבני נתונים יתווספו. נוסיף טבלה הדומה מבחינות מסוימות לטבלת ה- inodes ב- Unix. נקרא לה טבלת.dnodes שינוי נוסף הוא במבנה של directory.entries כל directory entry יצביע לכניסה בטבלת ה- dnodes במקום להצביע לבלוק הראשון של הקובץ. בכל כניסה כזו יהיו שני שדות. השדה הראשון מונה את מספר ההצבעות לרשומת ה- dnode והשדה השני מצביע לבלוק הראשון של הקובץ. ה- FAT נשאר ללא שינוי.

Question 2: FAT (2007a)

Question 2: FAT (2007a) כתבו פסאודו-קוד המתאר אל פעולתה של פרוצדורה new-path),hard-link(old-path, המממשת את הפקודה.hard-link )b Procedure hard-link(old-path, new-path) } // get directory-name and entry-name Convert new-path to <dname, ename> // allocate a new directory entry in directory dname new-entry allocate-new-entry(dname) new-entry.filename ename // locate old-path dnote entry dnode-entry-num locate-dnote-entry(old-path) // point from directory entry to dnode entry new-entry.dnode dnode-entry-num // Increment links number dnodes[dnodes-entry-num].links++ {

Question 2: FAT (2007a)?MS-DOS האם נדרשים שינויים נוספים בקוד של c( אם כן, ציינו אותם בקצרה. מובן כי כעת כל הפרוצדורות הפועלות על קבצים נדרשות לעבוד עם מבני הנתונים החדשים. כאשר נוצר קובץ חדש, יש לאתחל את מספר הלינקים של ה- dnode החדש ל- 1. כאשר מוחקים קובץ יש להפחית את מספר הלינקים של ה- dnode שלו באחד. רק אם מספר זה מתאפס, יש למחוק את הקובץ עצמו.

Question 3 (Moed b, 2007) נתון שרטוט של יישום שכבתי של לקוח ושרת במערכת.NFS

Question 3 (Moed b, 2007) הוסיפו לשרטוט cache גם אצל השרת וגם אצל הלקוח. ציינו איזה שכבה משתמשת ב- cache. נמקו במדויק את בחירתכם למיקום ה- cache. מה ההבדל במערכת NFS בין ה- cache של הלקוח והשרת? הסבירו את ההבדל ביתרונות ובחסרונות בשימוש ב- cache אצל הלקוח ואצל השרת..a.b

Question 3a (Moed b, 2007) Client kernel Server kernel System call layer v-nodes Virtual file system layer Virtual file system layer i-nodes Local FS1 Local FS2 NFS server NFS server Local FS1 Local FS2 r-nodes Buffer cache Buffer cache Message to server Message from client 25

Question 3b (Moed b, 2007) השרת הינו stateless ולכן לא נשמר שום מידע. גישה לשרת היא חדשה והשרת ניגש למערכת הקבצים הרגילה. הלקוח אינו stateless ולכן גם בקשות ה- NFS יכולות לעבור דרך ה- cache. כל

Question 4 (Moed b 2006) נתונה התוכנית: int main(char ** argv, int argc){ int fd=open("dugma1.txt",o_wronly,0666); if (fork()==0){ int fd2=dup(fd); sleep(10); write (fd2,"i was here second",17); }//if else{ write (fd,"i was here first",16); } } א- ב- בהנחה שבתחילת התכנית הקובץ dugma1.txt הוא ריק, מה תוכנו לאחר סיום התכנית? הסבירו. החלף את השורה האדומה על מנת לקבל תוצאה אחרת והסבר את השוני, בהתייחס למימוש מערכת הקבצים של.UNIX

Question 4 (Moed b 2006) 1. I was here firsti was here second 2. int fd2=open ( dugma1.txt,o_wronly,0666); output is : I was here second Why?

Open File Description Table & File Descriptor Table Parent s file descriptors table Child s file descriptors table Open files description table File position RW pointer to i-node File position RW pointer to i-node Unrelated process s file descriptors table File position RW pointer to i-node i-nodes table

Locking Files Two or more processes accessing a file together can cause race conditions. Ability to lock any number of bytes of a file. Two kinds of locks shared locks, exclusive locks C Function is int flock(int fd, int operation); flock is an advisory lock

Locking Files flock doesn t work over NFS Locking a whole file is wasteful. lockf(int fd, int cmd, off_t len) Allows locking over NFS by implementing another protocol (Network Lock Manager) No shared locking Also an advisory lock Commands: F_ULOCK (unlock), F_LOCK (lock [blocking]), F_TLOCK (test & lock [non-blocking]), F_TEST (test)

Question 4 (Moed b 2006) [revised] int main(char ** argv, int argc){ int stat; int fd=open("dugma1.txt",o_wronly,0666); if (fork()==0){ int fd2=open("dugma1.txt",o_wronly,0666); sleep(10); if (lockf(fd2,f_tlock,17)>=0){ write (fd2,"i was here second",17); } }//if else{ lockf(fd,f_tlock,16); write (fd,"i was here first",16); wait(&stat); } } שינו את הקוד. מה יהיה הפלט עכשיו? הסבר.

Question 4 (Moed b 2006).1.2 בשורה שהוספנו הוספנו מנעול non-blocking )השתמשנו בארגומנט.)F_TLOCK הקובץ יכיל שורה אחת בלבד: I was here first הסיבה לכך היא מכיוון שלא מתבצעת סגירה של הקובץ. אם נשנה את הארגומנט ל F_LOCK )כלומר כשבודקים את המנעול נמתין עד שישתחרר(, נקבל.deadlock ניתן לפתור זאת באחת משתי דרכים: לוותר על wait )סגנון רע( להוסיף close )באופן כללי תמיד נדאג לסגור קבצים שפתחנו!(. במקרה זה תודפס שורה אחת ובה: ומה יקרה כשנשתמש ב-?DUP I was here second

Question 5 (Moed a 2009) נתונה מערכת קבצים של לינוקס אשר תומכת בשיתוף קבצים.)NFS( א. במערכת קיימים שלושה סוגי מבני נתונים:. i-node, v-node, r-node הסבירו את תפקידו של כל אחד ממבני הנתונים הללו ואת הקשרים ביניהם. ב. נתון קטע הקוד הבא. int fd=open("data.txt",o_rdonly,0666); lseek(fd,50,seek_set); // Sets the offset to 50 write(fd,buf,150); // Write 150 bytes from buf lseek(fd,50,seek_set); // Sets the offset to 50 read(fd,buf,150); // Read 150 bytes into buf ידוע שהקובץ data.txt יושב על גבי שרת חיצוני )ולא במערכת הקבצים המקומית(. הסבירו אילו מן הפקודות שבקוד נשלחות לשרת ואילו לא. נמקו תשובתכם בקצרה )6 נק'(.

Question 5 (Moed a 2009) א. : i-node מבנה נתונים המתאר קובץ במערכת הקבצים המקומית : r-node מבנה נתונים אשר נמצא אצל הקליינט ומתאר קובץ במערכת קבצים מרוחקת ל- r-node i-nodeאו ומצביע או ל- VFS - נמצא בשכבת ה : v-node ה- System Call Layer "עובדת" רק מול. v-node כלומר, ה"דיבור" עם קבצים יתבצע באותה "שפה" בלי קשר אם הקובץ מקומי או מרוחק )הממשק המוחצן ע"י שכבה זו אינו מתייחס למיקום הקבצים(. r-node אליו מצביע v-node יתרגם את הפקודות להודעות עבור שרת מרוחק שעליו יושב הקובץ. ואילו i-node אשר אליו מצביע איזשהו v-node יתרגם את הפקודות להודעות למערכת הקבצים המקומית של מערכת ההפעלה.

Question 5 (Moed a 2009) ב. שורה 1: לא תשלח פקודת open לשרת, אלה פקודות lookup אשר תחזיר לקליינט.filehandle לאחר קבלת ה- filehandle הקליינט ייצר v-node ו r-node כאשר ה- v-node מצביע ל- r-node וה- r-node מחזיק את ה-.filehandle לשורה 1 התקבלו גם התשובות שבהן הנבחן רשם שה- open נשלח והשרת מחזיר FD וגם התשובות שבהן הנבחן רשם שה- open לא נשלח בגלל שהשרת הוא stateless שורה 2: השרת הוא stateless ולכן מידע כגון ה offset של הקובץ נמצא אצל הקליינט. כלומר פקודת lseek תמיד תתבצע בצד של הקליינט בלבד. שורה 3: השרת הוא stateless ולכן מידע כגון הרשאות כתיבה/קריאה של הקובץ נמצאות אצל הקליינט. מכיוון שהקובץ נפתח כ- RD_ONLY הקליינט יזהה שאסור לבצע פעולת כתיבה לקובץ. ולכן פקודת ה- write לא תשלח לשרת. שורה 4: ראה הסבר לשורה 2. שורה 5: מכיוון שהתוכן של הקובץ יושב אצל השרת )ולא אצל הקליינט( פקודת ה- 100. offset תשלח לשרת ותבקש את 150 הביטים מ- read

Question 5 (Moed a 2009) ג. נתון קטע הקוד הבא. int fd=open("data.txt",o_rdonly,0666); lseek(fd,0,seek_set); // Sets the offset to 0 read(fd,buf,500); read(fd,buf,500); read(fd,buf,1000); נתון גם כי לקליינט יש שכבת NFS caching והשרת שולח לקליינט בלוקים בגודל קבוע של. 1 KB הסבירו אילו מן הפקודות בקוד שלמעלה נשלחות לשרת ואילו לא. נמקו תשובתכם בקצרה ( 6 נק'(.

Question 5 (Moed a 2009) ג. הערה: בשאלה זו פקודת ה- read יכולה להחזיר יותר מידע ממה שהקליינט ביקש. כאשר המוטיבציה מאחורי קבלת מידע "נוסף", היא שסביר להניח שבאיזשהו שלב הקליינט ירצה לקרוא את המידע הנוסף הזה. שכבת ה- cache אשר בה יאוחסן המידע יכולה לחסוך גישות לשרת. שורה 1: )ראה הסבר לשורה 1 בסעיף ב'( שורה 2: )ראה הסבר לשורה 2 בסעיף ב'( שורה 3: הקליינט יראה שה- cache ריק ולכן עליו לקבל את תוכן הקובץ מהשרת. פקודת ה- read תשלח לשרת ותבקש את 500 הביטים מ- offset אפס. מכיוון שנתון שהשרת מחזיר תשובות בבלוקים של 1 KB הקליינט יקבל חזרה את תוכן הקובץ מ- 0 עד 1024 בייט ויאכסן את המידע ב- cache שורה 4: כעת הקליינט רוצה את תוכן הקובץ מ- 500 עד 1000 בייט. הפעם הקליינט יגלה שהמידע שהוא צריך יושב ב- cache ולכן פקודת ה- read לא תישלח לשרת, אלה תילקח המידע ישירות מה- cache שורה 5: כעת הקליינט רוצה את תוכן הקובץ מ 1000 עד 2000 בייט. אולם ל- cache יש רק את המידע עד הבייט ה- 1024 ולכן הפעם פקודת ה- read תישלח לשרת.

Question 5 (Moed a 2009) ד. נתונים שני תהליכים. התהליך הראשון פותח את הקובץ data.txt לכתיבה ולקריאה. התהליך השני מנסה למחוק את הקובץ בעודו פתוח ע"י התהליך הראשון. בהנחה ששני התהליכים רצים על מחשבים שונים )שני קליינטים שונים של השרת החיצוני(. האם המחיקה תצליח? נמקו בקצרה. בהנחה ששני התהליכים רצים על אותו מחשב )קליינט של השרת החיצוני(. האם המחיקה תצליח? נמקו בקצרה.1.2

Question 5 (Moed a 2009) השרת הוא stateless ולכן אין לו שום מידע לגבי איזה תהליכים פתחו את הקובץ.data.txt בהנחה שיש לקליינט הרשאות מתאימות, המחיקה תצליח. מכיוון ששני התהליכים רצים על אותה מערכת הפעלה באותו מחשב, מערכת ההפעלה של הקליינט יכולה לזהות שהקובץ פתוח )הקליינט הוא )statefull האם המחיקה תצליח? תלוי במערכת ההפעלה. נבחן שהבין שהפעם המחיקה תלויה בקליינט )ולא בשרת( וסטודנט שנתן הסבר מספק, קיבל את מלוא הנקודות. ד..1.2