Operating Systems, 132 Practical Session 2, Signals and Assignment 1 1.
Operating Systems , 132
description
Transcript of Operating Systems , 132
Operating Systems, 132
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
MS-DOS uses fixed size 32-byte directory entries
โข read-onlyโข hiddenโข systemโข archive
An index into the 64K โentry FAT
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 Hendler8
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.
10
EXT4 NTFS 6 FAT32
Allocation method Indexed Indexed, by โrunsโ Linked
File representation
i-node(default size 256KB)
MFT record(default size 1Kb)
Chain of clusters pointed from a Directory entry
Location of filename Directory entry Directory entry,
MFT record Directory entry
Location of attributes i-node MFT record Directory entry
Data accessi-node contain pointers with different levels of
indirection
For small files- the contents inside the MFT
record, for larger- organized as 'runs'
which may span multiple MFT records
Directory entryPoints to 1st link in
chain
Location of index table
i-nodes table immediately after the
superblockMFT anywhere, pointed
by MBRFAT anywhere,
pointed by MBR
Design compare
11
EXT4 NTFS 6 FAT32
Built in security Yes Yes No
Recoverability Yes, via data and metadata journaling
Yes, via metadata journaling No
Efficient disk usage Yes, via sparse files Yes, via compression,
sparse files No
Fragmentation problem No Some, tries to store
files sequentially Yes
Max file size 16TB(for 4k block)
16EB by design, 16TB by implementation 4GB
Max volume size 1EB(1EB=1,000,000TB) 16EB 2TB
Max filename length
255 chars(case sensitive)
255 chars(case sensitive)
Originally 8+3, extended to 255
(not case sensitive)
Hard links Yes Yes No
Soft links Yes Yes No
Features compare
12
EXT4 NTFS 6 FAT32
Pros
โข 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
โข 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
โข Simpleโข Widely supportedโข Efficient for small
files on small volumes and sequential access
Cons
โข Compatibility issues with other OS
โข Larger disk footprint than NTFS
โข Fragmentation problemโข Inefficient on small
volumesโข Performance degrades
when disk is almost fullโข Size of MFT grows with
usage
โข Obsoleteโข Not suitable for
large volumes and files
โข No recoverabilityโข No securityโข No user permissionsโข Fragmentation
reduce performance
Pros & Cons
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. 42. 14 , 19 , 8 , -1 , -1 , 9 , 3 , 2 , 5 , 10 , -1
0 X1 X2 EOF3 134 25 96 87 Free8 Y9 12
10 311 FREE12 EOF13 EOF14 FREE15 BAD
Not allocated
End of file
Marked as a bad block
6 8 4 2
5 9 12
10 3 13
File A:
File B:
File C:
Question 2: FAT (2007a)
ืืฉืืื ืื ืขืืืื ืืืฆืืข ืฉืื ืืืื )ืืืื ื ืื ืชืื ืื ืขื ืื ืช MS-DOSืืืงืื( ืฉื ืืขืจืืช ืืงืืฆืื ืฉื
ืืืืจ ืืฉืื ืื, ืชืชืืื . linksืืืืกืืฃ ืื ืชืืืื ื-MS-DOS:ืืฉืชื ืืคืงืืืืช ืืืืฉืืช ืืืืืช
ืืคืงืืื:โ soft-link old-path new-path
.old-path ืื new-path ืืืฉ ื-soft link ืืืฆืจืช ืืคืงืืื:โ hard-link old-path new-path
.old-path ืื new-path ืืืฉ ื-hard link ืืืฆืจืช
Question 2: FAT (2007a) MS-DOS ื ืงืืืืช( ืื ื ืจืืฆืื ืืืืกืืฃ ืืืขืจืืช ืืงืืฆืื ืฉื 13)ื.
ืืืื ืืืฆืข ืฉืื ืื ืืืฉืืื ืืืืืช , soft linksืชืืืื ื-. ืืืืื ืืืืกืืฃ ืืื ื ื ืชืื ืื ืืืฉืืFATื-
)a ืชืืจื ืืคืืจืื ืืืื ืืื ื ื ืชืื ืื ืฉืMS-DOS.ืืฉืชื ื ืืืืฆื
, ืืืฆืืื directory entry ื-flagืืฉืื ืื ืืืืื ืื ืืจืฉ ืืื ื ืชืืกืคืช ืื ืื. symbolic link ืืื ื entryืืื ืืงืืืฅ ืืืืฆืืข ืข"ื ื-
ืืื ื entry ืืืจื, ืชืืื ื ืฉื ืืงืืืฅ ืฉืฉืื ืืืคืืข ื-flagืืืืื ืื-(.old-path )ืืืืืจ, linkื-
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)c ืืื ื ืืจืฉืื ืฉืื ืืืื ื ืืกืคืื ืืงืื ืฉื )MS-DOS.ืื ืื, ืฆืืื ื ืืืชื ืืงืฆืจื ?
ืฉืื )ืื ืืฉื ื directories ืขืืืจืื ืขื ื-pathname ื-parsingืืืฉืจ ืืืฆืขืื )ืืชืืืช current directory ืื ื-root directoryืืืื( ืขื ืคื ืืกืืจ, ืืื ืื ื
ืื ื ืชืงืืื, ืืฉ ืืืืืง name(. ืขืืืจ ืื ืฉื relative path ืื absoluteืื ืืื ืฉืืืกืคื ื. ืื ืื, ืืฉ ืืงืจืื ืืช ืชืืื flag, ืข"ื ืืืืงืช ื-linkืื ืืื ืืืฆื
, ืืืืืฉืื ืืช ืคืขืืืช link ื-name, ืืืืืืฃ ืืช link ืืืฉืชื ื nameืืงืืืฅ .link ืืื ืืชืืืืช parsingื-
. ืืฉ ืืื ืืข ืืืืื link ื-link. ืืจืฉื ืืฆืืขืืช ืฉื bืืืืืืฉ ืฉืื ื ืืกืขืืฃ , ืืืฉื ืข"ื ืกืคืืจื ืฉื ืืกืคืจ ืืคืขืืื ืืื parsingืืื ืกืืคืืช ืืืืื ืคืขืืืช ื-
ืืืฆืืื ืขื ืืืืขืช ืฉืืืื ืืชืืืื ืืืืื ืืืืื ื ืืืืข linkืืชืืืื ื ืชืงื ื-ืืขืจื ืกืฃ ืฉื ืงืืข ืืจืืฉ. ืืคืฉืจืืช ื ืืกืคืช ืืื ืืื ืืข ืืจืืฉ ืืฆืืขืืช ืืื
ืืื ืงืื.
.false ื-linkืืืฉืจ ืืืฆืจืื ืงืืืฅ ืจืืื, ืืฉ ืืืชืื ืืช ืืื
Question 2: FAT (2007a) ืชืืืื MS-DOS ื ืงืืืืช( ืืขืช ื ืืกืืฃ ืืืขืจืืช ืืงืืฆืื ืฉื 12)ื.)ืื ืืื ืื FATืืืื ืืืฆืข ืฉืื ืื ืืืฉืืื ืืืืืช ื-, hard linksื-
ื ืืชื ืืืืขืืจ ืืืื ื ื ืชืื ืื ื ืืกืคืื(.a ืชืืจื ืืคืืจืื ืืืื ืืื ื ื ืชืื ืื ืฉื )MS-DOS ืืฉืชื ื ืืืืฆื, ืืืืื
ืืื ื ื ืชืื ืื ืืชืืืกืคื.
. Unix ื-inodesื ืืกืืฃ ืืืื ืืืืื ืืืืื ืืช ืืกืืืืืช ืืืืืช ื- directory. ืฉืื ืื ื ืืกืฃ ืืื ืืืื ื ืฉื dnodesื ืงืจื ืื ืืืืช
entries ืื .directory entry-ืืฆืืืข ืืื ืืกื ืืืืืช ื dnodes ืืืงืื ืืืฆืืืข ืืืืืง ืืจืืฉืื ืฉื ืืงืืืฅ. ืืื ืื ืืกื ืืื ืืืื ืฉื ื
ืฉืืืช. ืืฉืื ืืจืืฉืื ืืื ื ืืช ืืกืคืจ ืืืฆืืขืืช ืืจืฉืืืช FATื- ืืืฉืื ืืฉื ื ืืฆืืืข ืืืืืง ืืจืืฉืื ืฉื ืืงืืืฅ. dnodeื-
.ื ืฉืืจ ืืื ืฉืื ืื
Question 2: FAT (2007a)
Question 2: FAT (2007a)b) ืืชืื ืคืกืืืื-ืงืื ืืืชืืจ ืื ืคืขืืืชื ืฉื ืคืจืืฆืืืจืhard-link(old-path, new-path) ,
.hard-linkืืืืืฉืช ืืช ืืคืงืืื
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)
c) ืืื ื ืืจืฉืื ืฉืื ืืืื ื ืืกืคืื ืืงืื ืฉืMS-DOS ?.ืื ืื, ืฆืืื ื ืืืชื ืืงืฆืจื
ืืืื ืื ืืขืช ืื ืืคืจืืฆืืืจืืช ืืคืืขืืืช ืขื ืงืืฆืื ื ืืจืฉืืช ืืขืืื ืขื ืืื ื ืื ืชืื ืื ืืืืฉืื.
ืืืฉืจ ื ืืฆืจ ืงืืืฅ ืืืฉ, ืืฉ ืืืชืื ืืช ืืกืคืจ . ืืืฉืจ ืืืืงืื 1 ืืืืฉ ื-dnodeืืืื ืงืื ืฉื ื-
ืงืืืฅ ืืฉ ืืืคืืืช ืืช ืืกืคืจ ืืืื ืงืื ืฉื ืฉืื ืืืื. ืจืง ืื ืืกืคืจ ืื ืืชืืคืก, dnodeื-
ืืฉ ืืืืืง ืืช ืืงืืืฅ ืขืฆืื.
Question 3 (Moed b, 2007).NFSื ืชืื ืฉืจืืื ืฉื ืืืฉืื ืฉืืืชื ืฉื ืืงืื ืืฉืจืช ืืืขืจืืช
Question 3 (Moed b, 2007)
.a ืืืกืืคื ืืฉืจืืืcache ืื ืืฆื ืืฉืจืช ืืื ืืฆื ืืืงืื. ืฆืืื ื ืืืื ืฉืืื ืืฉืชืืฉืช
. ื ืืงื ืืืืืืง ืืช ืืืืจืชืื ืืืืงืื cacheื-.cacheื-
.b ืื ืืืืื ืืืขืจืืชNFS -ืืื ื cache ืฉื ืืืงืื ืืืฉืจืช? ืืกืืืจื ืืช ืืืืื ืืืชืจืื ืืช
ืืฆื ืืืงืื ืืืฆื cacheืืืืกืจืื ืืช ืืฉืืืืฉ ื-ืืฉืจืช.
Question 3a (Moed b, 2007)Client kernel Server kernel
System call layer
Virtual file system layer
v-nodes
Local FS1
Local FS2
NFS server
Buffer cache
Message to server
Virtual file system layer
Local FS1
Local FS2
NFS server
Buffer cache
Message from client
i-nodes
r-nodes
25
Question 3b (Moed b, 2007)
ืืืื ืื ื ืฉืืจ ืฉืื ืืืืข. statelessืืฉืจืช ืืื ื โขืื ืืืฉื ืืฉืจืช ืืื ืืืฉื ืืืฉืจืช ื ืืืฉ
ืืืขืจืืช ืืงืืฆืื ืืจืืืื. NFS ืืืื ืื ืืงืฉืืช ื-statelessืืืงืื ืืื ื โข
.cacheืืืืืืช ืืขืืืจ ืืจื ื-
Question 4 (Moed b 2006)
ืืื ืื ืฉืืชืืืืช ื-ืืชืื ืืช ืืงืืืฅ
dugma1.txt ,ืืื ืจืืง ืื ืชืืื ื ืืืืจ ืกืืื
ืืชืื ืืช? ืืกืืืจื.
ืืืืฃ ืืช ืืฉืืจื ื-ืืืืืื ืขื ืื ืช
ืืงืื ืชืืฆืื ืืืจืช ืืืกืืจ ืืช ืืฉืื ื, ืืืชืืืืก ืืืืืืฉ
ืืขืจืืช ืืงืืฆืื ืฉื UNIX .
ื ืชืื ื ืืชืืื ืืช:
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); }}
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
Unrelated processโs
file descriptors
table
File positionRW
pointer to i-node
File positionRW
pointer to i-node
File positionRW
pointer to i-nodei-nodes table
Open files description table
29
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); }}//ifelse{
lockf(fd,F_TLOCK,16); write (fd,"I was here first",16); wait(&stat);
}
}
ืฉืื ื ืืช ืืงืื.ืื ืืืื ืืคืื ืขืืฉืื?
ืืกืืจ.
Question 4 (Moed b 2006)
)ืืฉืชืืฉื ื non-blockingืืฉืืจื ืฉืืืกืคื ื ืืืกืคื ื ืื ืขืื (. ืืงืืืฅ ืืืื ืฉืืจื ืืืช ืืืื:F_TLOCKืืืจืืืื ื
I was here firstืืกืืื ืืื ืืื ืืืืืื ืฉืื ืืชืืฆืขืช ืกืืืจื ืฉื ืืงืืืฅ. ืื ื ืฉื ื
)ืืืืืจ ืืฉืืืืงืื ืืช ืืื ืขืื ื ืืชืื ืขื F_LOCKืืช ืืืจืืืื ื ื .deadlockืฉืืฉืชืืจืจ(, ื ืงืื
ื ืืชื ืืคืชืืจ ืืืช ืืืืช ืืฉืชื ืืจืืื: )ืกืื ืื ืจืข(waitืืืืชืจ ืขื 1.
)ืืืืคื ืืืื ืชืืื ื ืืื ืืกืืืจ ืงืืฆืื ืฉืคืชืื ื!(.closeืืืืกืืฃ 2.
ืืืงืจื ืื ืชืืืคืก ืฉืืจื ืืืช ืืื:
I was here second? DUPืืื ืืงืจื ืืฉื ืฉืชืืฉ ื-
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 50write(fd,buf,150); // Write 150 bytes from buflseek(fd,50,SEEK_SET); // Sets the offset to 50read(fd,buf,150); // Read 150 bytes into buf
ืืืฉื ืขื ืืื ืฉืจืช ืืืฆืื ื )ืืื ืืืขืจืืช ืืงืืฆืื data.txtืืืืข ืฉืืงืืืฅ ืืืงืืืืช(.
ืืกืืืจื ืืืื ืื ืืคืงืืืืช ืฉืืงืื ื ืฉืืืืช ืืฉืจืช ืืืืื ืื. ื ืืงื ืชืฉืืืชืื ื ืง'(.6ืืงืฆืจื )
Question 5 (Moed a 2009)ื.
i-nodeืืื ื ื ืชืื ืื ืืืชืืจ ืงืืืฅ ืืืขืจืืช ืืงืืฆืื ืืืงืืืืช :
r-node ืืื ื ื ืชืื ืื ืืฉืจ ื ืืฆื ืืฆื ืืงืืืื ื ืืืชืืจ ืงืืืฅ ืืืขืจืืช ืงืืฆืื : ืืจืืืงืช
v-node -ื ืืฆื ืืฉืืืช ื : VFS -ืืืฆืืืข ืื ื i-node -ืื ื r-node
. ืืืืืจ, ื"ืืืืืจ" ืขื ืงืืฆืื v-node"ืขืืืืช" ืจืง ืืื System Call Layerื- ืืชืืฆืข ืืืืชื "ืฉืคื" ืืื ืงืฉืจ ืื ืืงืืืฅ ืืงืืื ืื ืืจืืืง )ืืืืฉืง ืืืืืฆื
ืืชืจืื v-node ืืืื ืืฆืืืข r-nodeืข"ื ืฉืืื ืื ืืื ื ืืชืืืืก ืืืืงืื ืืงืืฆืื(. ืืฉืจ i-nodeืืช ืืคืงืืืืช ืืืืืขืืช ืขืืืจ ืฉืจืช ืืจืืืง ืฉืขืืื ืืืฉื ืืงืืืฅ. ืืืืื
ืืชืจืื ืืช ืืคืงืืืืช ืืืืืขืืช ืืืขืจืืช ืืงืืฆืื v-nodeืืืื ืืฆืืืข ืืืืฉืื ืืืงืืืืช ืฉื ืืขืจืืช ืืืคืขืื.
Question 5 (Moed a 2009)ื.
ืืฉืจ ืชืืืืจ ืืงืืืื ื lookup ืืฉืจืช, ืืื ืคืงืืืืช open ืื ืชืฉืื ืคืงืืืช :1ืฉืืจื filehandle -ืืืืจ ืงืืืช ื .filehandle ืืงืืืื ื ืืืฆืจ v-node ื r-node -ืืืฉืจ ื
v-node -ืืฆืืืข ืr-node -ืื r-node -ืืืืืง ืืช ื filehandle ืืชืงืืื 1. ืืฉืืจื ืืื FD ื ืฉืื ืืืฉืจืช ืืืืืจ openืื ืืชืฉืืืืช ืฉืืื ืื ืืื ืจืฉื ืฉื-
stateless ืื ื ืฉืื ืืืื ืฉืืฉืจืช ืืื openืืชืฉืืืืช ืฉืืื ืื ืืื ืจืฉื ืฉื- ืฉื ืืงืืืฅ ื ืืฆื ืืฆื offset ืืืื ืืืืข ืืืื ื stateless ืืฉืจืช ืืื :2ืฉืืจื
ืชืืื ืชืชืืฆืข ืืฆื ืฉื ืืงืืืื ื ืืืื.lseekืืงืืืื ื. ืืืืืจ ืคืงืืืช
ืืืื ืืืืข ืืืื ืืจืฉืืืช ืืชืืื/ืงืจืืื ืฉื ืืงืืืฅ stateless ืืฉืจืช ืืื :3ืฉืืจื ืืงืืืื ื ืืืื ืฉืืกืืจ RD_ONLYื ืืฆืืืช ืืฆื ืืงืืืื ื. ืืืืืื ืฉืืงืืืฅ ื ืคืชื ื-
ืื ืชืฉืื ืืฉืจืช.writeืืืฆืข ืคืขืืืช ืืชืืื ืืงืืืฅ. ืืืื ืคืงืืืช ื-
.2 ืจืื ืืกืืจ ืืฉืืจื :4ืฉืืจื
ืืืืืื ืฉืืชืืื ืฉื ืืงืืืฅ ืืืฉื ืืฆื ืืฉืจืช )ืืื ืืฆื ืืงืืืื ื( ืคืงืืืช ื- :5ืฉืืจื read ืืืืืื ื- 150 ืชืฉืื ืืฉืจืช ืืชืืงืฉ ืืช offset 100.
Question 5 (Moed a 2009)ื. ื ืชืื ืงืืข ืืงืื ืืื.
int fd=open("data.txt",O_RDONLY,0666);lseek(fd,0,SEEK_SET); // Sets the offset to 0read(fd,buf,500);read(fd,buf,500);read(fd,buf,1000);
ืืืฉืจืช ืฉืืื ืืงืืืื ื ืืืืงืื ืืืืื NFS cachingื ืชืื ืื ืื ืืงืืืื ื ืืฉ ืฉืืืช .KB 1ืงืืืข ืฉื
ืืกืืืจื ืืืื ืื ืืคืงืืืืช ืืงืื ืฉืืืขืื ื ืฉืืืืช ืืฉืจืช ืืืืื ืื. ื ืืงื ื ืง'(.6ืชืฉืืืชืื ืืงืฆืจื )
Question 5 (Moed a 2009)ื.
ืืืืื ืืืืืืจ ืืืชืจ ืืืืข ืืื ืฉืืงืืืื ื ืืืงืฉ. ืืืฉืจ readืืขืจื: ืืฉืืื ืื ืคืงืืืช ื- ืืืืืืืฆืื ืืืืืจื ืงืืืช ืืืืข "ื ืืกืฃ", ืืื ืฉืกืืืจ ืืื ืื ืฉืืืืืฉืื ืฉืื ืืงืืืื ื
ืืฉืจ ืื ืืืืืกื ืืืืืข ืืืืื cacheืืจืฆื ืืงืจืื ืืช ืืืืืข ืื ืืกืฃ ืืื. ืฉืืืช ื- ืืืกืื ืืืฉืืช ืืฉืจืช.
ืืกืขืืฃ ื'(1)ืจืื ืืกืืจ ืืฉืืจื : 1ืฉืืจื
ืืกืขืืฃ ื'(2)ืจืื ืืกืืจ ืืฉืืจื : 2ืฉืืจื
ืจืืง ืืืื ืขืืื ืืงืื ืืช ืชืืื ืืงืืืฅ ืืืฉืจืช. ืคืงืืืช cacheืืงืืืื ื ืืจืื ืฉื- : 3ืฉืืจื ืืคืก. ืืืืืื ืฉื ืชืื ืฉืืฉืจืช offset ืืืืืื ื- 500 ืชืฉืื ืืฉืจืช ืืชืืงืฉ ืืช readื-
1024 ืขื 0 ืืงืืืื ื ืืงืื ืืืจื ืืช ืชืืื ืืงืืืฅ ื- KB 1ืืืืืจ ืชืฉืืืืช ืืืืืงืื ืฉื cacheืืืื ืืืืืกื ืืช ืืืืืข ื-
ืืืื. ืืคืขื ืืงืืืื ื ืืืื 1000 ืขื 500ืืขืช ืืงืืืื ื ืจืืฆื ืืช ืชืืื ืืงืืืฅ ื- : 4ืฉืืจื ืื ืชืืฉืื ืืฉืจืช, ืืื read ืืืื ืคืงืืืช ื- cacheืฉืืืืืข ืฉืืื ืฆืจืื ืืืฉื ื-
cacheืชืืืงื ืืืืืข ืืฉืืจืืช ืื-
ืืฉ cache ืืืื. ืืืื ื- 2000 ืขื 1000ืืขืช ืืงืืืื ื ืจืืฆื ืืช ืชืืื ืืงืืืฅ ื โ : 5ืฉืืจื ืชืืฉืื ืืฉืจืช.read ืืืื ืืคืขื ืคืงืืืช ื- 1024ืจืง ืืช ืืืืืข ืขื ืืืืื ื-
Question 5 (Moed a 2009) ืืืชืืื data.txtื. ื ืชืื ืื ืฉื ื ืชืืืืืื. ืืชืืืื ืืจืืฉืื ืคืืชื ืืช ืืงืืืฅ
ืืืงืจืืื. ืืชืืืื ืืฉื ื ืื ืกื ืืืืืง ืืช ืืงืืืฅ ืืขืืื ืคืชืื ืข"ื ืืชืืืื ืืจืืฉืื.
. ืืื ืื ืฉืฉื ื ืืชืืืืืื ืจืฆืื ืขื ืืืฉืืื ืฉืื ืื )ืฉื ื ืงืืืื ืืื ืฉืื ืื ืฉื 1ืืฉืจืช ืืืืฆืื ื(. ืืื ืืืืืงื ืชืฆืืื? ื ืืงื ืืงืฆืจื.
. ืืื ืื ืฉืฉื ื ืืชืืืืืื ืจืฆืื ืขื ืืืชื ืืืฉื )ืงืืืื ื ืฉื ืืฉืจืช ืืืืฆืื ื(. 2ืืื ืืืืืงื ืชืฆืืื? ื ืืงื ืืงืฆืจื
Question 5 (Moed a 2009)ื.
ืืืื ืืื ืื ืฉืื ืืืืข ืืืื ืืืื ืชืืืืืื ืคืชืื ืืช statelessืืฉืจืช ืืื 1.. ืืื ืื ืฉืืฉ ืืงืืืื ื ืืจืฉืืืช ืืชืืืืืช, ืืืืืงื data.txtืืงืืืฅ ืชืฆืืื.
ืืืืืื ืฉืฉื ื ืืชืืืืืื ืจืฆืื ืขื ืืืชื ืืขืจืืช ืืคืขืื ืืืืชื ืืืฉื, 2.ืืขืจืืช ืืืคืขืื ืฉื ืืงืืืื ื ืืืืื ืืืืืช ืฉืืงืืืฅ ืคืชืื )ืืงืืืื ื ืืื
statefull ืืื ืืืืืงื ืชืฆืืื? ืชืืื ืืืขืจืืช ืืืคืขืื. ื ืืื ืฉืืืื )ืฉืืคืขื ืืืืืงื ืชืืืื ืืงืืืื ื )ืืื ืืฉืจืช( ืืกืืืื ื ืฉื ืชื ืืกืืจ
ืืกืคืง, ืงืืื ืืช ืืืื ืื ืงืืืืช.