2.File Operations(文件操作) Open Files Open-File Table Several pieces of data are needed to manage open files: File pointer:pointer to last read/write location, process-dependent File-open count:counter of number of times a file is open-to allow removal of data from open-file table when last processes closes it Disk location of the file:the information needed to locate the file on disk,always is kept in memory Access rights:per-process access mode information 4口”484在4色,主月QC
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2. File Operations (文件操作) ▶ Open Files & Open-File Table ▶ Several pieces of data are needed to manage open files: ▶ File pointer: pointer to last read/write location, process-dependent ▶ File-open count: counter of number of times a file is open – to allow removal of data from open-file table when last processes closes it ▶ Disk location of the file: the information needed to locate the file on disk, always is kept in memory ▶ Access rights: per-process access mode information
2.File Operations(文件操作) Open file locking:Provided by some OSes and FSes allow one process to lock a file and prevent other processes from gaining access to it functionality is similar to reader-writer locks OS-or FS-dependent 1.Mandatory:for example,Windows OSes,or access is denied depending on locks held and requested; OS ensures locking integrity 2.Advisory:for example,UNIX processes can find status of locks and decide what to do up to software developers 4口”484在4色,主月QC
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2. File Operations (文件操作) ▶ Open file locking: Provided by some OSes and FSes ▶ allow one process to lock a file and prevent other processes from gaining access to it ▶ functionality is similar to reader-writer locks ▶ OS- or FS-dependent 1. Mandatory: for example, Windows OSes, or ▶ access is denied depending on locks held and requested; ▶ OS ensures locking integrity 2. Advisory: for example, UNIX ▶ processes can find status of locks and decide what to do ▶ up to software developers
3.File Types-Name,Extension file type usual extension function executable exe,com,bin or none ready-to-run machine-language progra object obj.o compiled,machine language,not linked source code C,cc,java,pas,asm,a source code in various languages batch bat,sh commands to the command interpreter text txt,doc textual data,documents work processor wp,tex,rtf,doc various word-processor formats library lib,a,so,dll libraries of routines for programmers print or view ps,pdf,jpg ASCll or binary file in a format for printi viewing archive arc,zip,tar related files grouped into one,sometim compressed,for archiving/storage multimedia mpeg,mov,rm,mp3,avi binary file containing audio or A/V information 4口”48+4在4色主)QC
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3. File Types – Name, Extension file type usual extension function executable exe, com, bin or none ready-to-run machine-language program object obj, o compiled, machine language, not linked source code c, cc, java, pas, asm, a source code in various languages batch bat, sh commands to the command interpreter text txt, doc textual data, documents work processor wp, tex, rtf, doc various word-processor formats library lib, a, so, dll libraries of routines for programmers print or view ps, pdf, jpg ASCII or binary file in a format for printing or viewing archive arc, zip, tar related files grouped into one, sometimes compressed, for archiving/storage multimedia mpeg, mov, rm, mp3, avi binary file containing audio or A/V information
4.File Structure Sometimes,file types can indicate the internal structure of file 一File structures(文件结构)(逻辑上) None-sequence of words,bytes Simple record structure Lines Fixed length; Variable length Complex Structures Formatted document Relocatable load file Can simulate last two with first method 4口”484在4色,主月QC
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4. File Structure ▶ Sometimes, file types can indicate the internal structure of file ▶ File structures(文件结构)(逻辑上) ▶ None - sequence of words, bytes ▶ Simple record structure ▶ Lines ▶ Fixed length; ▶ Variable length ▶ Complex Structures ▶ Formatted document ▶ Relocatable load file ▶ Can simulate last two with first method
4.File Structure System-supported file structures Most modern OSes support a minimal number of file structures directly Example:UNIX sees every file as a sequence of 8-bit bytes Benefits: Applications have more flexibility Simplifies the OS 4口”4814在,4色,主)QC
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4. File Structure ▶ System-supported file structures ▶ Most modern OSes support a minimal number of file structures directly ▶ Example: UNIX sees every file as a sequence of 8-bit bytes ▶ Benefits: ▶ Applications have more flexibility ▶ Simplifies the OS