Download

Unix Case Study






Advertisement
Download Presentation
Comments
wilma
From:
|  
(828) |   (0) |   (0)
Views: 115 | Added: 22-03-2012
Rate Presentation: 3 0
Description:
Thursday, 22 March 2012. CS2051 Lecture 17. 2. UNIX History
Unix Case Study

An Image/Link below is provided (as is) to

Download Policy: Content on the Website is provided to you AS IS for your information and personal use only and may not be sold or licensed nor shared on other sites. SlideServe reserves the right to change this policy at anytime. While downloading, If for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.











- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -




1. Thursday, 22 March 2012 CS2051 Lecture 17 1 Unix Case Study ?The UNIX programming environment is unusually rich and productive.? - Kernighan and Pike Reading: Bacon, 23

2. Thursday, 22 March 2012 CS2051 Lecture 17 2 UNIX History & Motivation Program Development Environment UNIX - weak pun on ?MULTICS? Initially (1969) single-user, soon (1973) multi-user timesharing system Written in ?C? (developed at Bell Labs to support Unix) Fundamental Architectural Design finished in 1978 Small size, modular, clean design; source distribution Kernel, Environment + Software Tools

3. Thursday, 22 March 2012 CS2051 Lecture 17 3 UNIX History

4. Thursday, 22 March 2012 CS2051 Lecture 17 4 Machine Architecture - Overview Programmer Interface: System calls (file manipulation; process control; information) System programs (e.g., mkdir, rm, cp, ?)

5. Thursday, 22 March 2012 CS2051 Lecture 17 5 Virtual Machine Memory <= 4Gb space, virtual (paged), software segments Kernel (shared by all processes) Text, Data, Heap, Stack User File ID?s - handles for interaction Files Shared Memory Region Network Connections System Calls - procedure-like interfaces Central Process Table

6. Thursday, 22 March 2012 CS2051 Lecture 17 6 Process Model Process Creation (replica address space created) process_id = fork() (NB:heavyweight; cf lightweight) Executing a Program result = execve(name, parameters) Wait for Child Process process_id = wait() Terminate (address space removed) exit(n) Zombie process: exited but not terminated

7. Thursday, 22 March 2012 CS2051 Lecture 17 7 The Process Process has its own: Unique process identifier Address space UFID?s for interacting with files, networks, etc. Signal handling vector Used to handle exceptional conditions (similar to software interrupts) UID and GIDs - user ID and group Ids govern permission checks Scheduling priorities Flow of Control Threads allow multiple flows of control in shared address space: Limited Kernel support Foreground jobs vs Background jobs Properties inherited from parent.

8. Thursday, 22 March 2012 CS2051 Lecture 17 8 The Shell Shell: the user process which executes programs (command interpreter) User types command Shell reads command (read from input) Search path Shell forks child process and execve program Shell waits for termination of child cm1 <arg_list_1> & cm2 <arg_list_2>

9. Thursday, 22 March 2012 CS2051 Lecture 17 9 Standard I/O and Redirection (Most) processes expect three file descriptors to be open when they start: Standard input; standard output; standard error Shell provides simple syntax for changing what files are open for I/O (redirection): ls > myfile (output of ls to file myfile) ls >> myfile (append output to myfile) mail rizos < myfile (input from myfile) x < a > b (input from a and output to b) make ppp > & errs, ...

10. Thursday, 22 March 2012 CS2051 Lecture 17 10 The shell is more... Shell variables (type set) PATH=$PATH:/bin:/usr/bin echo $PATH alias: alias p more; alias rm ?rm -i? Programmable (e.g., /opt/teaching/bin/msg) #!/bin/csh -f switch ( $#argv ) case 0: cat /etc/motd breaksw default: if ( $1 !~ [123456789] && $1 != "10" ) then echo "Usage: msg [message_no]" exit 0 endif more /opt/teaching/msg/msg{$1} endsw

11. Thursday, 22 March 2012 CS2051 Lecture 17 11 Inter Process Communication Pipes The previous command?s output is passed as input to the following: ls ?la | grep Nov | grep 23 manipulated through file identifiers pipe system call Events (Signals) - visible in non-privileged code originated in program or kernel individually ignored, caught or handled (recursively) per process signal(SIGHUP, SIG_IGN, NULL); Interrupts Device-driver specific - visible only in privileged code

12. Thursday, 22 March 2012 CS2051 Lecture 17 12 Sockets General interface for communicating processes (local or over the network) Socket: endpoint of communication Domain: AF_UNIX; AF_INET; AF_NS System calls: socket_id = socket(domain,type,protocol) bind: name is bound to a socket connect(local_socket_id, remote_socket) listen(); accept(); close()

13. Thursday, 22 March 2012 CS2051 Lecture 17 13 Process Management Kernel keeps process descriptor (control block) information for scheduling/control. Pointers to stack/data/text; system data structure (kernel stack for kernel mode). Scheduling: ?fair?, timeshared, dynamic priority scheduling Delayed jobs: at 0630 myjob for one-off deferral cron for regular jobs (hourly, daily, weekly, monthly, etc)

14. Thursday, 22 March 2012 CS2051 Lecture 17 14 File System Representation of a file is the basic concept Directories are just files with a special format Access mechanisms: ufid = open(name, access); nbytes = read(ufid, &buffer, bufsize); nbytes = write(ufid, &buffer, nbytes); close(ufid) Types of file access: Default file access is sequential Random access (to byte boundary) is supported Non-sequential file access supported by libraries

15. Thursday, 22 March 2012 CS2051 Lecture 17 15

16. Thursday, 22 March 2012 CS2051 Lecture 17 16 File System: the mount concept

17. Thursday, 22 March 2012 CS2051 Lecture 17 17

18. Thursday, 22 March 2012 CS2051 Lecture 17 18 The inode concept Information about a specific file on disk is stored into an inode. Owner, last time info, permissions, size, links to the file, and: The inode contains 15 pointers to the disk blocks containing data contents: 12 pointers to direct blocks 1 single-indirect; 1 double-indirect; 1 triple-indirect What is the maximum possible file size?

19. Thursday, 22 March 2012 CS2051 Lecture 17 19 Memory Management Paging introduced with BSD 3 (process 2: pagedaemon) LRU approximation with second-chance. Round-robin check of all pages Reference bit (set to 1 every time frame is accessed).

20. Thursday, 22 March 2012 CS2051 Lecture 17 20

21. Thursday, 22 March 2012 CS2051 Lecture 17 21 I/O and Device Drivers Drivers are privileged code (not user-supplied) Driver cannot use application API Application::driver API is driver-specific ?Streams? offer some rationality:

22. Thursday, 22 March 2012 CS2051 Lecture 17 22 Device Drivers Filesystem Drivers: (e.g. disks, CDROM) block I/O cached in kernel: read ahead/write behind generally synchronous transfers Character I/O (e.g. terminals, ...) synchronous or asynchronous transfers no block buffer cache 1 Application I/O :: 1 Device transfer

23. Thursday, 22 March 2012 CS2051 Lecture 17 23 Summary UNIX is widespread in server marketplace Ideally suited for: Software development Rapid prototyping Web servers Team-level servers and larger Question marks: scalability GUI support Real-time responses


Other Related Presentations

Copyright © 2014 SlideServe. All rights reserved | Powered By DigitalOfficePro