SlideShare a Scribd company logo
1 of 33
โครงสร้า งระบบแฟ้ม
 File-System Structure
Learning Objectives

                      เพื่อศึกษาหลักการจัดการระบบแฟ้ม
                      เพื่อให้เข้าใจถึงโครงสร้างของแฟ้ม และสารบบ รวมทั้ง
                      คุณลักษณะประการต่างๆ ของแฟ้ม และการจัดการแฟ้ม




วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 2
                            ั
File-System Management

                      File Concept

                      Access Methods

                      Directory Structure

                      File System Mounting

                      File Sharing

                      Protection




วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 3
                            ั
แนวคิด เกี่ย วกับ แฟ้ม
                                                 File Concept
                      แฟ้ม คือ พื้นที่อยูเชิงตรรกะที่เรียงต่อเนื่องกัน (Contiguous
                                         ่
                      logical address space)

                      Types:
                         แฟ้มข้อมูล (Data file)
                            numeric
                                 character
                                 binary
                         แฟ้มโปรแกรม (Program file)




วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 4
                            ั
แนวคิด เกี่ย วกับ แฟ้ม
                                                 File Concept
                      คุณลักษณะของแฟ้ม
                            เช่น ชื่อ, ตัวระบุ (identifier), ประเภท, ที่อยู่, ขนาด, การป้องกัน, วัน
                             เดือน ปี และข้อมูลเกี่ยวกับผู้ใช้
                      คำาสั่งปฏิบัติการเกียวกับแฟ้ม
                                          ่
                            เช่น การสร้าง, การเขียน, การอ่าน, การย้ายตำาแหน่งภายใน, การลบ,
                             การตัดทิ้ง OS บางชนิด จะมี ตัวชี้แฟ้ม (File pointer), การนับการเปิด
                             แฟ้ม, ตำาแหน่งหน่วยเก็บแฟ้ม, สิทธิการเข้าถึง (access rights) เป็นต้น
                      ประเภทของแฟ้ม
                            ประกอบด้วยชือ (file name) และส่วยขยาย (file extension)
                                         ่
                      โครงสร้างแฟ้ม และแฟ้มสนับสนุน
                      โครงสร้างแฟ้มภายใน
                            อาจเป็นตำาแหน่งของ offset, block, sector เพื่อใช้ในการแปลงจากที่
                             อยูเชิงตรรกะ (logical address) ไปเป็นที่อยู่เชิงกายภาพ (physical
                                ่
                             address)




วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 5
                            ั
File Structure

                      ไม่มี (None) – เป็นลำาดับของ words หรือ bytes
                      โครงสร้างระเบียนอย่างง่าย (Simple record structure)
                         Lines
                         Fixed length
                         Variable length
                      โครงสร้างซับซ้อน (Complex Structures)
                         Formatted document
                         Relocatable load file
                      ผู้ตัดสินเลือกโครงสร้างของแฟ้ม
                         Operating system
                         Program




วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 6
                            ั
     Operating System
File Attributes

                      Name – only information kept in human-readable form.
                      Type – needed for systems that support different types.
                      Location – pointer to file location on device.
                      Size – current file size.
                      Protection – controls who can do reading, writing,
                      executing.
                      Time, date, and user identification – data for
                      protection, security, and usage monitoring.
                      Information about files are kept in the directory structure,
                      which is maintained on the disk.




วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 7
                            ั
     Operating System
File Operations

                      Create
                      Write
                      Read
                      Reposition within file – file seek
                      Delete
                      Truncate
                      Open(Fi) – search the directory structure on disk for entry
                      Fi, and move the content of entry to memory.
                      Close (Fi) – move the content of entry Fi in memory to
                      directory structure on disk.




วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 8
                            ั
     Operating System
File Types – Name, Extension




วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 9
                            ั
Access Methods
                       การเข้า ถึง โดยลำา ดับ (Sequential Access )
                                                   read next
                                                   write next
                                                   reset
                                                   no read after last write
                                                            (rewrite)
                       การเข้า ถึง โดยตรง (Direct Access)
                                                   read n
                                                   write n
                                                   position to n
                                                            read next
                                                            write next
                                                   rewrite n
                       n = relative block number




วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 10
                            ั
Sequential-access File




วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 11
                            ั
Simulation of Sequential Access on a Direct-access File




วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 12
                            ั
Example of Index and Relative
                                     Files




วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 13
                            ั
Directory Structure
                   กลุ่มของโหนดต่างๆ ที่บรรจุไว้ด้วยข้อมูลเกียวกับแฟ้มทั้งหมด
                                                             ่


                  Directory




                    Files
                                          F1           F2                      F4
                                                                   F3
                                                                                            Fn


             ทั้ง directory structure และ files ที่อยูบนดิสก์
                                                      ่
             เวลาสำารองข้อมูลจะต้องเก็บโครงสร้างทั้งคู่ไว้บนเทป

วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 14
                            ั
A Typical File-system Organization




วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 15
                            ั
Information in a Device Directory

                      Name
                      Type
                      Address
                      Current length
                      Maximum length
                      Date last accessed (for archival)
                      Date last updated (for dump)
                      Owner ID (who pays)
                      Protection information (discuss later)




วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 16
                            ั
Operations Performed on Directory

                      Search for a file
                      Create a file
                      Delete a file
                      List a directory
                      Rename a file
                      Traverse the file system




วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 17
                            ั
เกณฑ์ก ารจัด องค์ก รสารบบเชิง ตรรกะ

                      ความสะดวก (Efficiency) – เพื่อให้ค้นหาไฟล์ได้อย่าง
                      รวดเร็ว
                      โดยชื่อ (Naming) – เพื่อความสะดวกต่อผู้ใช้
                      โดยกลุ่ม (Grouping) – กลุ่มเชิงตรรกะตามคุณลักษณะของ
                      แฟ้ม เช่น all Java programs, all games, …




วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 18
                            ั
Single-Level Directory


                 มีสารบบเดียวสำาหรับผู้ใช้ทุกคน




            Naming problem

            Grouping problem




วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 19
                            ั
Two-Level Directory

                   แยกสารบบตามผู้ใช้แต่ละคน




                   Path name
                   ผู้ใช้สามารถตั้งชื่อแฟ้มเหมือนกัน
                   ง่ายต่อการค้นหา
                   ไม่สามารถแบ่งตามความจุที่ใช้

วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 20
                            ั
Tree-Structured Directories




วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 21
                            ั
Tree-Structured Directories (Cont.)

                      ง่ายต่อการค้นหา (Efficient searching)

                      ตามความจุของกลุ่ม (Grouping Capability)

                      สารบบปัจจุบัน (Current directory) สารบบที่ทำางาน (working
                      directory)
                         cd /spell/mail/prog
                         type list




วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 22
                            ั
Tree-Structured Directories (Cont.)

                 ชื่อเส้นทาง (path name) เชิง สัม บูร ณ์ (Absolute) หรือเชิง
                 สัมพัทธ์ (relative)
                 การสร้างชื่อแฟ้มเสร็จแล้วในสารบบปัจจุบัน
                 Delete a file
                                 rm <file-name>
                 การสร้างสารบบย่อยในสารบบปัจจับน
                                          mkdir <dir-name>
                 Example: if in current directory /mail
                                 mkdir count
                                                            mail

                                       prog       copy prt exp count


           Deleting “mail” ⇒ deleting the entire subtree rooted by “mail”.
วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 23
                            ั
สารบบกราฟแบบมีว ง
                                  Acyclic-Graph Directories
                    มีการใช้ร่วมกันของ subdirectories และ files




วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 24
                            ั
Acyclic-Graph Directories (Cont.)

                      มีสองชื่อที่แตกต่างกัน (ชื่อพ้องกัน-aliasing)

                      ถ้า dict ถูกลบไป list ⇒ จะเป็นพอนย์เตอร์ลอย (dangling
                      pointer)
                      Solutions:
                         ใช้พอยน์เตอร์ย้อนกล้บ (Backpointers), จึงสามารถลบทุกพอยน์
                          เตอร์ได้
                          ระเบียนทีมขนาดแปรผัน (Variable size records) ได้จะมีปัญหา
                                   ่ ี
                         ใช้พอยน์เตอร์ย้อนกล้บ (Backpointers) โดยใช้การจัดองค์กรแบบ
                          daisy chain organization
                         Entry-hold-count solution.




วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 25
                            ั
General Graph Directory




วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 26
                            ั
General Graph Directory (Cont.)

                      ทำาอย่างไรจึงรับประกันว่าไม่มีวงกลม (no cycles)?
                         ยินยอมให้มเพียง link ไปยัง files ไม่ใช่ subdirectories
                                    ี
                         แต่จะสะสมขยะ
                         ทุกครั้งที่เพิมลิงก์ใหม่ ให้ใช้อัลกอริธึมการตรวจหาวงกลม (cycle
                                        ่
                             detection algorithm) เพื่อดูว่าเกิดปัญหาหรือไม่




วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 27
                            ั
File System Mounting

                      file system จะต้องมีการ mounted ก่อนเริ่มใช้งาน

                      unmounted file system จะ mounted ณ mount point.




วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 28
                            ั
(a) Existing. (b) Unmounted
                                        Partition




วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 29
                            ั
Mount Point




วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 30
                            ั
การแบ่ง ปัน แฟ้ม
                                                      File Sharing
                      การใช้แฟ้มร่วมกันเป็นสิ่งที่ต้องการบนระบบ multi-user
                      systems

                      การแบ่งปันอาจแบ่งปันผ่าน protection scheme

                      บนระบบกระจาย (distributed systems) การแบ่งปันแฟ้มอาจทำา
                      ข้ามเครือข่าย

                      Network File System (NFS) จึงเป็นวิธีการทั่วไปที่ใช้ในการ
                      แบ่งปันระบบแฟ้มบนระบบกระจาย (distributed file-sharing
                      method)




วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 31
                            ั
Protection

                      เจ้าของหรือผู้สร้างแฟ้ม (File owner/creator) ควรสามารถ
                      ควบคุม
                         สามารถทำาอะไรได้บ้าง
                         โดยใคร


                      ประเภทการเข้าถึง (Types of access)
                         Read
                         Write
                         Execute
                         Append
                         Delete
                         List




วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 32
                            ั
Access Lists and Groups
                  โหมดการเข้าถึง (Mode of access): read, write, execute
                  ประเภทผู้ใช้
                                                                     RWX
                                a) owner access         7      ⇒     111
                                                                     RWX
                                b) group access         6      ⇒ 110
                                                                     RWX
                                c) public access        1      ⇒ 001
                  Ask manager to create a group (unique name), say G,
                  and add some users to the group.
                  For a particular file (say game) or subdirectory, define an
                  appropriate access.

                                                    owner      group       public


                                                     chmod      761    game

            Attach a group to a file
                                                   chgrp          G      game
วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 33
                            ั

More Related Content

What's hot (6)

ระบบปฏิบัติการ
ระบบปฏิบัติการระบบปฏิบัติการ
ระบบปฏิบัติการ
 
ระบบปฏิบัติการ.Ppt
 ระบบปฏิบัติการ.Ppt  ระบบปฏิบัติการ.Ppt
ระบบปฏิบัติการ.Ppt
 
Mi sch3
Mi sch3Mi sch3
Mi sch3
 
Operating System Chapter 5
Operating System Chapter 5Operating System Chapter 5
Operating System Chapter 5
 
นางสาว หัทยา เชื้อสมเกียรติ ม.5
นางสาว หัทยา เชื้อสมเกียรติ ม.5นางสาว หัทยา เชื้อสมเกียรติ ม.5
นางสาว หัทยา เชื้อสมเกียรติ ม.5
 
นางสาว อรอนงค์ สุขาวรรณ
นางสาว อรอนงค์ สุขาวรรณนางสาว อรอนงค์ สุขาวรรณ
นางสาว อรอนงค์ สุขาวรรณ
 

Viewers also liked (7)

LinkedIn How To
LinkedIn How ToLinkedIn How To
LinkedIn How To
 
2 ca-computer systems (wichet p.'s conflicted copy 2012-12-18)
2 ca-computer systems (wichet p.'s conflicted copy 2012-12-18)2 ca-computer systems (wichet p.'s conflicted copy 2012-12-18)
2 ca-computer systems (wichet p.'s conflicted copy 2012-12-18)
 
6 ca-virtual memory structure (wichet p.'s conflicted copy 2012-12-17)
6 ca-virtual memory structure (wichet p.'s conflicted copy 2012-12-17)6 ca-virtual memory structure (wichet p.'s conflicted copy 2012-12-17)
6 ca-virtual memory structure (wichet p.'s conflicted copy 2012-12-17)
 
Lance
LanceLance
Lance
 
Social Media for Classes & Clubs
Social Media for Classes & ClubsSocial Media for Classes & Clubs
Social Media for Classes & Clubs
 
การใช้ This is/That is
การใช้ This is/That isการใช้ This is/That is
การใช้ This is/That is
 
9 ca-io systems structure (wichet p.'s conflicted copy 2012-12-17)
9 ca-io systems structure (wichet p.'s conflicted copy 2012-12-17)9 ca-io systems structure (wichet p.'s conflicted copy 2012-12-17)
9 ca-io systems structure (wichet p.'s conflicted copy 2012-12-17)
 

Similar to 7 ca-file-system management

8 ca-file system implementation (wichet p.'s conflicted copy 2012-12-17)
8 ca-file system implementation (wichet p.'s conflicted copy 2012-12-17)8 ca-file system implementation (wichet p.'s conflicted copy 2012-12-17)
8 ca-file system implementation (wichet p.'s conflicted copy 2012-12-17)
krissapat
 
10 ca-mass-storage system structure (wichet p.'s conflicted copy 2012-12-17)
10 ca-mass-storage system structure (wichet p.'s conflicted copy 2012-12-17)10 ca-mass-storage system structure (wichet p.'s conflicted copy 2012-12-17)
10 ca-mass-storage system structure (wichet p.'s conflicted copy 2012-12-17)
krissapat
 
หน่วยที่ 1เรื่อง การจัดการข้อมูล ธนพงษ์ น่านกร ม.5
หน่วยที่ 1เรื่อง การจัดการข้อมูล ธนพงษ์  น่านกร ม.5หน่วยที่ 1เรื่อง การจัดการข้อมูล ธนพงษ์  น่านกร ม.5
หน่วยที่ 1เรื่อง การจัดการข้อมูล ธนพงษ์ น่านกร ม.5
palmyZommanow
 
หน่วยที่ 1
หน่วยที่ 1หน่วยที่ 1
หน่วยที่ 1
palmyZommanow
 
หน่วยที่1 เรื่อง เทคโนโลยีการสื่อสาร นางสาว สิรินยา ปาโจด ม.5
หน่วยที่1 เรื่อง เทคโนโลยีการสื่อสาร นางสาว สิรินยา  ปาโจด ม.5หน่วยที่1 เรื่อง เทคโนโลยีการสื่อสาร นางสาว สิรินยา  ปาโจด ม.5
หน่วยที่1 เรื่อง เทคโนโลยีการสื่อสาร นางสาว สิรินยา ปาโจด ม.5
สิรินยา ปาโจด
 
หน่วยที่1 เรื่อง เทคโนโลยีการสื่อสาร นางสาว สิรินยา ปาโจด ม.5
หน่วยที่1 เรื่อง เทคโนโลยีการสื่อสาร นางสาว สิรินยา  ปาโจด ม.5หน่วยที่1 เรื่อง เทคโนโลยีการสื่อสาร นางสาว สิรินยา  ปาโจด ม.5
หน่วยที่1 เรื่อง เทคโนโลยีการสื่อสาร นางสาว สิรินยา ปาโจด ม.5
สิรินยา ปาโจด
 
นางสาว อรอนงค์ สุขาวรรณ ม.5 เลขที่ 16 com
นางสาว อรอนงค์ สุขาวรรณ ม.5 เลขที่ 16 comนางสาว อรอนงค์ สุขาวรรณ ม.5 เลขที่ 16 com
นางสาว อรอนงค์ สุขาวรรณ ม.5 เลขที่ 16 com
lovelovejung
 
นางสาว อรอนงค์ สุขาวรรณ ม.5 เลขที่ 16 com
นางสาว อรอนงค์ สุขาวรรณ ม.5 เลขที่ 16 comนางสาว อรอนงค์ สุขาวรรณ ม.5 เลขที่ 16 com
นางสาว อรอนงค์ สุขาวรรณ ม.5 เลขที่ 16 com
Luckfon Fonew
 
การจัดการฐานข้อมูล
การจัดการฐานข้อมูลการจัดการฐานข้อมูล
การจัดการฐานข้อมูล
ABELE Snvip
 
บทที่1 ความรู้พื้นฐาน
บทที่1 ความรู้พื้นฐานบทที่1 ความรู้พื้นฐาน
บทที่1 ความรู้พื้นฐาน
tapabnum
 
Database basic new
Database basic newDatabase basic new
Database basic new
Qoo Kratai
 
งาคอม
งาคอมงาคอม
งาคอม
lookpair
 

Similar to 7 ca-file-system management (20)

8 ca-file system implementation (wichet p.'s conflicted copy 2012-12-17)
8 ca-file system implementation (wichet p.'s conflicted copy 2012-12-17)8 ca-file system implementation (wichet p.'s conflicted copy 2012-12-17)
8 ca-file system implementation (wichet p.'s conflicted copy 2012-12-17)
 
Ch11th
Ch11thCh11th
Ch11th
 
10 ca-mass-storage system structure (wichet p.'s conflicted copy 2012-12-17)
10 ca-mass-storage system structure (wichet p.'s conflicted copy 2012-12-17)10 ca-mass-storage system structure (wichet p.'s conflicted copy 2012-12-17)
10 ca-mass-storage system structure (wichet p.'s conflicted copy 2012-12-17)
 
หน่วยที่ 1เรื่อง การจัดการข้อมูล ธนพงษ์ น่านกร ม.5
หน่วยที่ 1เรื่อง การจัดการข้อมูล ธนพงษ์  น่านกร ม.5หน่วยที่ 1เรื่อง การจัดการข้อมูล ธนพงษ์  น่านกร ม.5
หน่วยที่ 1เรื่อง การจัดการข้อมูล ธนพงษ์ น่านกร ม.5
 
หน่วยที่ 1
หน่วยที่ 1หน่วยที่ 1
หน่วยที่ 1
 
Eoffice1
Eoffice1Eoffice1
Eoffice1
 
หน่วยที่1 เรื่อง เทคโนโลยีการสื่อสาร นางสาว สิรินยา ปาโจด ม.5
หน่วยที่1 เรื่อง เทคโนโลยีการสื่อสาร นางสาว สิรินยา  ปาโจด ม.5หน่วยที่1 เรื่อง เทคโนโลยีการสื่อสาร นางสาว สิรินยา  ปาโจด ม.5
หน่วยที่1 เรื่อง เทคโนโลยีการสื่อสาร นางสาว สิรินยา ปาโจด ม.5
 
หน่วยที่1 เรื่อง เทคโนโลยีการสื่อสาร นางสาว สิรินยา ปาโจด ม.5
หน่วยที่1 เรื่อง เทคโนโลยีการสื่อสาร นางสาว สิรินยา  ปาโจด ม.5หน่วยที่1 เรื่อง เทคโนโลยีการสื่อสาร นางสาว สิรินยา  ปาโจด ม.5
หน่วยที่1 เรื่อง เทคโนโลยีการสื่อสาร นางสาว สิรินยา ปาโจด ม.5
 
E office2011 3
E office2011 3E office2011 3
E office2011 3
 
E office1
E office1E office1
E office1
 
Work3 14
Work3 14Work3 14
Work3 14
 
บทที่6
บทที่6บทที่6
บทที่6
 
นางสาว อรอนงค์ สุขาวรรณ ม.5 เลขที่ 16 com
นางสาว อรอนงค์ สุขาวรรณ ม.5 เลขที่ 16 comนางสาว อรอนงค์ สุขาวรรณ ม.5 เลขที่ 16 com
นางสาว อรอนงค์ สุขาวรรณ ม.5 เลขที่ 16 com
 
นางสาว อรอนงค์ สุขาวรรณ ม.5 เลขที่ 16 com
นางสาว อรอนงค์ สุขาวรรณ ม.5 เลขที่ 16 comนางสาว อรอนงค์ สุขาวรรณ ม.5 เลขที่ 16 com
นางสาว อรอนงค์ สุขาวรรณ ม.5 เลขที่ 16 com
 
Unix Operation System
Unix Operation SystemUnix Operation System
Unix Operation System
 
การจัดการฐานข้อมูล
การจัดการฐานข้อมูลการจัดการฐานข้อมูล
การจัดการฐานข้อมูล
 
บทที่1 ความรู้พื้นฐาน
บทที่1 ความรู้พื้นฐานบทที่1 ความรู้พื้นฐาน
บทที่1 ความรู้พื้นฐาน
 
งาน Ppt 6401
งาน Ppt 6401 งาน Ppt 6401
งาน Ppt 6401
 
Database basic new
Database basic newDatabase basic new
Database basic new
 
งาคอม
งาคอมงาคอม
งาคอม
 

7 ca-file-system management

  • 2. Learning Objectives เพื่อศึกษาหลักการจัดการระบบแฟ้ม เพื่อให้เข้าใจถึงโครงสร้างของแฟ้ม และสารบบ รวมทั้ง คุณลักษณะประการต่างๆ ของแฟ้ม และการจัดการแฟ้ม วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 2 ั
  • 3. File-System Management File Concept Access Methods Directory Structure File System Mounting File Sharing Protection วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 3 ั
  • 4. แนวคิด เกี่ย วกับ แฟ้ม File Concept แฟ้ม คือ พื้นที่อยูเชิงตรรกะที่เรียงต่อเนื่องกัน (Contiguous ่ logical address space) Types:  แฟ้มข้อมูล (Data file)  numeric  character  binary  แฟ้มโปรแกรม (Program file) วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 4 ั
  • 5. แนวคิด เกี่ย วกับ แฟ้ม File Concept คุณลักษณะของแฟ้ม  เช่น ชื่อ, ตัวระบุ (identifier), ประเภท, ที่อยู่, ขนาด, การป้องกัน, วัน เดือน ปี และข้อมูลเกี่ยวกับผู้ใช้ คำาสั่งปฏิบัติการเกียวกับแฟ้ม ่  เช่น การสร้าง, การเขียน, การอ่าน, การย้ายตำาแหน่งภายใน, การลบ, การตัดทิ้ง OS บางชนิด จะมี ตัวชี้แฟ้ม (File pointer), การนับการเปิด แฟ้ม, ตำาแหน่งหน่วยเก็บแฟ้ม, สิทธิการเข้าถึง (access rights) เป็นต้น ประเภทของแฟ้ม  ประกอบด้วยชือ (file name) และส่วยขยาย (file extension) ่ โครงสร้างแฟ้ม และแฟ้มสนับสนุน โครงสร้างแฟ้มภายใน  อาจเป็นตำาแหน่งของ offset, block, sector เพื่อใช้ในการแปลงจากที่ อยูเชิงตรรกะ (logical address) ไปเป็นที่อยู่เชิงกายภาพ (physical ่ address) วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 5 ั
  • 6. File Structure ไม่มี (None) – เป็นลำาดับของ words หรือ bytes โครงสร้างระเบียนอย่างง่าย (Simple record structure)  Lines  Fixed length  Variable length โครงสร้างซับซ้อน (Complex Structures)  Formatted document  Relocatable load file ผู้ตัดสินเลือกโครงสร้างของแฟ้ม  Operating system  Program วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 6 ั Operating System
  • 7. File Attributes Name – only information kept in human-readable form. Type – needed for systems that support different types. Location – pointer to file location on device. Size – current file size. Protection – controls who can do reading, writing, executing. Time, date, and user identification – data for protection, security, and usage monitoring. Information about files are kept in the directory structure, which is maintained on the disk. วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 7 ั Operating System
  • 8. File Operations Create Write Read Reposition within file – file seek Delete Truncate Open(Fi) – search the directory structure on disk for entry Fi, and move the content of entry to memory. Close (Fi) – move the content of entry Fi in memory to directory structure on disk. วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 8 ั Operating System
  • 9. File Types – Name, Extension วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 9 ั
  • 10. Access Methods การเข้า ถึง โดยลำา ดับ (Sequential Access ) read next write next reset no read after last write (rewrite) การเข้า ถึง โดยตรง (Direct Access) read n write n position to n read next write next rewrite n n = relative block number วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 10 ั
  • 11. Sequential-access File วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 11 ั
  • 12. Simulation of Sequential Access on a Direct-access File วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 12 ั
  • 13. Example of Index and Relative Files วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 13 ั
  • 14. Directory Structure กลุ่มของโหนดต่างๆ ที่บรรจุไว้ด้วยข้อมูลเกียวกับแฟ้มทั้งหมด ่ Directory Files F1 F2 F4 F3 Fn ทั้ง directory structure และ files ที่อยูบนดิสก์ ่ เวลาสำารองข้อมูลจะต้องเก็บโครงสร้างทั้งคู่ไว้บนเทป วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 14 ั
  • 15. A Typical File-system Organization วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 15 ั
  • 16. Information in a Device Directory Name Type Address Current length Maximum length Date last accessed (for archival) Date last updated (for dump) Owner ID (who pays) Protection information (discuss later) วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 16 ั
  • 17. Operations Performed on Directory Search for a file Create a file Delete a file List a directory Rename a file Traverse the file system วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 17 ั
  • 18. เกณฑ์ก ารจัด องค์ก รสารบบเชิง ตรรกะ ความสะดวก (Efficiency) – เพื่อให้ค้นหาไฟล์ได้อย่าง รวดเร็ว โดยชื่อ (Naming) – เพื่อความสะดวกต่อผู้ใช้ โดยกลุ่ม (Grouping) – กลุ่มเชิงตรรกะตามคุณลักษณะของ แฟ้ม เช่น all Java programs, all games, … วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 18 ั
  • 19. Single-Level Directory มีสารบบเดียวสำาหรับผู้ใช้ทุกคน Naming problem Grouping problem วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 19 ั
  • 20. Two-Level Directory แยกสารบบตามผู้ใช้แต่ละคน Path name ผู้ใช้สามารถตั้งชื่อแฟ้มเหมือนกัน ง่ายต่อการค้นหา ไม่สามารถแบ่งตามความจุที่ใช้ วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 20 ั
  • 21. Tree-Structured Directories วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 21 ั
  • 22. Tree-Structured Directories (Cont.) ง่ายต่อการค้นหา (Efficient searching) ตามความจุของกลุ่ม (Grouping Capability) สารบบปัจจุบัน (Current directory) สารบบที่ทำางาน (working directory)  cd /spell/mail/prog  type list วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 22 ั
  • 23. Tree-Structured Directories (Cont.) ชื่อเส้นทาง (path name) เชิง สัม บูร ณ์ (Absolute) หรือเชิง สัมพัทธ์ (relative) การสร้างชื่อแฟ้มเสร็จแล้วในสารบบปัจจุบัน Delete a file rm <file-name> การสร้างสารบบย่อยในสารบบปัจจับน mkdir <dir-name> Example: if in current directory /mail mkdir count mail prog copy prt exp count Deleting “mail” ⇒ deleting the entire subtree rooted by “mail”. วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 23 ั
  • 24. สารบบกราฟแบบมีว ง Acyclic-Graph Directories มีการใช้ร่วมกันของ subdirectories และ files วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 24 ั
  • 25. Acyclic-Graph Directories (Cont.) มีสองชื่อที่แตกต่างกัน (ชื่อพ้องกัน-aliasing) ถ้า dict ถูกลบไป list ⇒ จะเป็นพอนย์เตอร์ลอย (dangling pointer) Solutions:  ใช้พอยน์เตอร์ย้อนกล้บ (Backpointers), จึงสามารถลบทุกพอยน์ เตอร์ได้ ระเบียนทีมขนาดแปรผัน (Variable size records) ได้จะมีปัญหา ่ ี  ใช้พอยน์เตอร์ย้อนกล้บ (Backpointers) โดยใช้การจัดองค์กรแบบ daisy chain organization  Entry-hold-count solution. วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 25 ั
  • 26. General Graph Directory วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 26 ั
  • 27. General Graph Directory (Cont.) ทำาอย่างไรจึงรับประกันว่าไม่มีวงกลม (no cycles)?  ยินยอมให้มเพียง link ไปยัง files ไม่ใช่ subdirectories ี  แต่จะสะสมขยะ  ทุกครั้งที่เพิมลิงก์ใหม่ ให้ใช้อัลกอริธึมการตรวจหาวงกลม (cycle ่ detection algorithm) เพื่อดูว่าเกิดปัญหาหรือไม่ วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 27 ั
  • 28. File System Mounting file system จะต้องมีการ mounted ก่อนเริ่มใช้งาน unmounted file system จะ mounted ณ mount point. วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 28 ั
  • 29. (a) Existing. (b) Unmounted Partition วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 29 ั
  • 30. Mount Point วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 30 ั
  • 31. การแบ่ง ปัน แฟ้ม File Sharing การใช้แฟ้มร่วมกันเป็นสิ่งที่ต้องการบนระบบ multi-user systems การแบ่งปันอาจแบ่งปันผ่าน protection scheme บนระบบกระจาย (distributed systems) การแบ่งปันแฟ้มอาจทำา ข้ามเครือข่าย Network File System (NFS) จึงเป็นวิธีการทั่วไปที่ใช้ในการ แบ่งปันระบบแฟ้มบนระบบกระจาย (distributed file-sharing method) วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 31 ั
  • 32. Protection เจ้าของหรือผู้สร้างแฟ้ม (File owner/creator) ควรสามารถ ควบคุม  สามารถทำาอะไรได้บ้าง  โดยใคร ประเภทการเข้าถึง (Types of access)  Read  Write  Execute  Append  Delete  List วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 32 ั
  • 33. Access Lists and Groups โหมดการเข้าถึง (Mode of access): read, write, execute ประเภทผู้ใช้ RWX a) owner access 7 ⇒ 111 RWX b) group access 6 ⇒ 110 RWX c) public access 1 ⇒ 001 Ask manager to create a group (unique name), say G, and add some users to the group. For a particular file (say game) or subdirectory, define an appropriate access. owner group public chmod 761 game Attach a group to a file chgrp G game วิเ ชษฐ์ พลายมาศ | ระบบปฏิบ ต ิก าร (OS: Operating Systems) | การจัดการระบบแฟ้ม (File-System Management) | 33 ั