Introduction to Embedded Systems - PowerPoint PPT Presentation

introduction to embedded systems n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Introduction to Embedded Systems PowerPoint Presentation
Download Presentation
Introduction to Embedded Systems

play fullscreen
1 / 19
Download Presentation
Introduction to Embedded Systems
137 Views
axel
Download Presentation

Introduction to Embedded Systems

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. Introduction to Embedded Systems Dr. Jerry Shiao, Silicon Valley University SILICON VALLEY UNIVERSITY CONFIDENTIAL

  2. File System • Review Inode a) Logical structure of current directory. File, Chapter3, is created in current directory. b) Contents of current directory. Directory entry contains pair <inode # / filename>. • c) Relationship among a directory entry, Inode Table, and physical file contents. • Inode # index into the Inode Table. • Inode Table entry contains the physical location of file on disk. SILICON VALLEY UNIVERSITY CONFIDENTIAL

  3. File System Virtual File System (VFS) User space has the applications and glibc (provides API file system calls: open, read, write, close). System call interface acts as a switch, funneling system calls from user space to the appropriate endpoints in kernel space. VFS exports APIs and abstracts them to individual file systems. Inode cache and Directory cache provides a pool of recently-used file system objects. Directory cache speeds up translation from file pathname to inode. Individual file systems exports APIs that is used by the VFS. Buffer cache buffers the requests between the file systems and the block devices that they manipulate (for faster access). Spring 2014 SILICON VALLEY UNIVERSITY CONFIDENTIAL 3

  4. File System Virtual File System (VFS) Superblock Object Superblock Object Inode Object Inode Object Inode Cache Inode Cache Process 1 File Object Dentry Object Dentry Object Dentry Object Dentry Object Process 2 File Object Dentry Cache Disk File Process 1 File Object Process 2 File Object Dentry Cache File Object: Stores info about interaction between open file and process. Dentry Object: Stores info about linking directory entry (file name) and file. Inode Object: Stores info about specific file (inode number identifies file). The file control block. Superblock Object: Stores info about mounted filesystem. The filesystem control block. Spring 2014 SILICON VALLEY UNIVERSITY CONFIDENTIAL 4

  5. Linux File System Virtual File System (VFS) struct file_system_type links together currently-supported file systems (/proc/filesystems). struct vfsmount links together file systems currently mounted. Link to struct superblock. struct superblock represents a file system. Manage inodes: alloc_inode, destroy_inode, read_inode, write_inode, sync_fs. struct inode represents an object (file or directory) in the file system with unique identifier. Metadata to manage objects in the file system struct inode_operations: Operations that operate on inode. struct file_operations: Methods related to files and directories (the standard system calls). Spring 2014 SILICON VALLEY UNIVERSITY CONFIDENTIAL 5

  6. Linux File System Virtual File System (VFS) Inode represents an object in the file system with a unique identifier (translating filename). struct file_operations abstractions (i.e. read/write/open ) allow all I/O operations to have common interface. The indirect calls (i.e. callback functions) are APIs specific to the file system. To achieve the abstraction (i.e. “black box operation) to the user, common API to the user through glibc library and common callback function signature to the I/O functions. Spring 2014 SILICON VALLEY UNIVERSITY CONFIDENTIAL 6

  7. File System • Hard Links • Hard link creates a file entry (new file name) in directory with the same inode index as the linked file. • ln [ options ] existing-file new-file • ln [ options ] existing-file-list directory • - f : Force creation of link. • - n : Do not create the link if “new-file” exists. • - s : Create symbolic link to “existing-file”. • NOTE: • < no “– s” > : Create a hard link to “existing-file”. • < “directory” > : The user MUST have execute permission for all the directories in the path leading to the file. SILICON VALLEY UNIVERSITY CONFIDENTIAL

  8. File System Create hard link. The inode index for linked file and file are the same. Link count is 2. • Hard Links Current Directory • $ ls -il total 12 2630032 -rw-r--r-x 1 sau users 102 2012-10-26 00:47 Chapter1 2630033 -rw-r--r-- 1 sau users 102 2012-10-26 00:47 Chapter2 2630034 -rw-r--r-- 1 sau users 79 2012-10-29 14:23 Chapter3 • $ ln Chapter3 Chapter3.hard • $ ls -il total 16 2630032 -rw-r--r-x 1 sau users 102 2012-10-26 00:47 Chapter1 2630033 -rw-r--r-- 1 sau users 102 2012-10-26 00:47 Chapter2 2630034 -rw-r--r-- 2 sau users 79 2012-10-29 14:23 Chapter3 2630034 -rw-r--r-- 2 sau users 79 2012-10-29 14:23 Chapter3.hard • $ rm Chapter3 • $ ls -il total 12 2630032 -rw-r--r-x 1 sau users 102 2012-10-26 00:47 Chapter1 2630033 -rw-r--r-- 1 sau users 102 2012-10-26 00:47 Chapter2 2630034 -rw-r--r-- 1 sau users 79 2012-10-29 14:23 Chapter3.hard • $ Remove only removes the entry in the directory. File is physically still on disk. Link count is 1. SILICON VALLEY UNIVERSITY CONFIDENTIAL

  9. File System • Link Count • Number of different directory entries pointing to inode of the object (i.e. directory or file). • File: Number of hard links to that file. • $ ls -il memo6 2630044 -rw-r--r-x 1 sau users 253 2012-10-29 16:16 memo6 • Directory: Number of directory entries connecting local directory to Linux file system. • $ ls -a.  ..  students  students_2  students.gz $ ls -lddrwxr-xr-x 2 student1 student1 4096 2013-10-19 02:06 .$ mkdirtest_dir$ ls -a.  ..  students  students_2  students.gz  test_dir$ ls -lddrwxr-xr-x 3 student1 student1 4096 2013-10-19 02:06 . SILICON VALLEY UNIVERSITY CONFIDENTIAL

  10. File System • Create Hard Link a) Logical structure of current directory. Hard link, Chapter3.hard, is linked to file, Chapter3 in current directory. b) Contents of current directory. Directory entry contains pair <inode # / filename> for Chapter3.hard. The inode# is same as file Chapter3. • c) Relationship among a directory entry, Inode Table, and physical file contents. • Inode # index into the Inode Table for both Chapter3 and Chapter3.hard. SILICON VALLEY UNIVERSITY CONFIDENTIAL

  11. File System • Hard Link Different Directory SILICON VALLEY UNIVERSITY CONFIDENTIAL

  12. File System Create hard link. The inode index for linked file and file are the same. Link count is 2. • Hard Links Different Directory • $ ls -il memos/memo6 2630044 -rw-r--r-x 1 sau users 253 2012-10-29 16:16 memos/memo6 • $ ln memos/memo6 memo6.hard • $ ls -il memos/memo6 2630044 -rw-r--r-x 2 sau users 253 2012-10-29 16:16 memos/memo6 • $ ls -il memo6.hard 2630044 -rw-r--r-x 2 sau users 253 2012-10-29 16:16 memo6.hard • $ • $ rm memos/memo6 • $ ls -il memos/memo6 ls: cannot access memos/memo6: No such file or directory • $ ls -il memo6.hard 2630044 -rw-r--r-x 1 sau users 253 2012-10-29 16:16 memo6.hard • $ Remove only removes the entry in the directory. File is physically still on disk. Link count is 1. SILICON VALLEY UNIVERSITY CONFIDENTIAL

  13. File System • Hard Links Limitations • Cannot use Hard Links between files on different file systems. • # ln /usr/bin/zip my_zip ln: creating hard link `my_zip' => `/usr/bin/zip': Invalid cross-device link • Moving a hard linked file to different file system causes physical copy of file to be made. • $ ls -il memo6.hard 2630045 -rw-r--r-x 2 sau users 253 2012-10-29 16:25 memo6.hard • $ ls -il memos/memo6 2630045 -rw-r--r-x 2 sau users 253 2012-10-29 16:25 memos/memo6 • $ mv memo6.hard /tmp • $ ls -il /tmp/memo6.hard • 953686 -rw-r--r-x 1 sau users 253 2012-10-29 16:25 /tmp/memo6.hard SILICON VALLEY UNIVERSITY CONFIDENTIAL

  14. File System • Soft Links • Does not have any of the Hard Link issues. • Soft link creates a new file entry (new file name and new inode index) in directory. • ln [ options ] existing-file new-file • ln [ options ] existing-file-list directory • - f : Force creation of link. • - n : Do not create the link if “new-file” exists. • - s : Required. Create symbolic link to “existing-file”. SILICON VALLEY UNIVERSITY CONFIDENTIAL

  15. File System • Soft Links Current Directory • $ ls -il Chapter3 2630032 -rw-r--r-x 1 sau users 102 2012-10-26 00:47 Chapter3 • $ ln -s Chapter3 Chapter3.soft • $ ls -il Chapter3 Chapter3.soft 2630032 -rw-r--r-x 1 sau users 102 2012-10-26 00:47 Chapter3 2630044 lrwxrwxrwx1 sau users 8 2012-10-29 18:12 Chapter3.soft -> Chapter3 • $ • Create soft link. • The inode index for linked file and file are different. These are different files. • Original file is file type “-”, an ordinary file. Link file is type “l”, a link file. • Link count 1. • File sizes are different. Link file is 8 bytes, the length of “Chapter3”, the pathname is placed in the link file. SILICON VALLEY UNIVERSITY CONFIDENTIAL

  16. File System • Soft Links • Create soft link. • The inode index for linked file and file are different. These are different files. • Original file is file type “-”, an ordinary file. Link file is type “l”, a link file. • Link count 1. • File sizes are different. Link file is 8 bytes, the length of “Chapter3”, the pathname is placed in the link file. SILICON VALLEY UNIVERSITY CONFIDENTIAL

  17. File System • Soft Links Pros and Cons • Pros • Establish symbolic link between files across file systems. • Establish symbolic link between directories. • Symbolic linked file edited by editor does not change filename. • Cons • If the file that the symbolic link points to is moved from one directory to another, it can no longer be accessed via the link. • UNIX has to support an additional file type (the link type) and a new file has to be created for every link. • Symbolic links also result in slow file operations because, for every reference to the file, the link file has to be opened and read in order to reach the actual file. SILICON VALLEY UNIVERSITY CONFIDENTIAL

  18. Assignment 9 SILICON VALLEY UNIVERSITY CONFIDENTIAL

  19. Assignment 9 SILICON VALLEY UNIVERSITY CONFIDENTIAL