CONTENTS IN DETAIL 1 HISTORY AND STANDARDS 1

Size: px
Start display at page:

Download "CONTENTS IN DETAIL 1 HISTORY AND STANDARDS 1"

Transcription

1 CONTENTS IN DETAIL PREFACE xxxi 1 HISTORY AND STANDARDS A Brief History of UNIX and C A Brief History of Linux The GNU Project The Linux Kernel Standardization The C Programming Language The First POSIX Standards X/Open Company and The Open Group SUSv3 and POSIX SUSv4 and POSIX UNIX Standards Timeline Implementation Standards Linux, Standards, and the Linux Standard Base Summary FUNDAMENTAL CONCEPTS The Core Operating System: The Kernel The Shell Users and Groups Single Directory Hierarchy, Directories, Links, and Files File I/O Model Programs Processes Memory Mappings Static and Shared Libraries Interprocess Communication and Synchronization Signals Threads Process Groups and Shell Job Control Sessions, Controlling Terminals, and Controlling Processes Pseudoterminals Date and Time Client-Server Architecture Realtime The /proc File System Summary SYSTEM PROGRAMMING CONCEPTS System Calls Library Functions The Standard C Library; The GNU C Library (glibc) Handling Errors from System Calls and Library Functions Notes on the Example Programs in This Book Command-Line Options and Arguments Common Functions and Header Files TLPI_FINAL_RRD.pdf 11

2 3.6 Portability Issues Feature Test Macros System Data Types Miscellaneous Portability Issues Summary Exercise FILE I/O: THE UNIVERSAL I/O MODEL Overview Universality of I/O Opening a File: open() The open() flags Argument Errors from open() The creat() System Call Reading from a File: read() Writing to a File: write() Closing a File: close() Changing the File Offset: lseek() Operations Outside the Universal I/O Model: ioctl() Summary Exercises FILE I/O: FURTHER DETAILS Atomicity and Race Conditions File Control Operations: fcntl() Open File Status Flags Relationship Between File Descriptors and Open Files Duplicating File Descriptors File I/O at a Specified Offset: pread() and pwrite() Scatter-Gather I/O: readv() and writev() Truncating a File: truncate() and ftruncate() Nonblocking I/O I/O on Large Files The /dev/fd Directory Creating Temporary Files Summary Exercises PROCESSES Processes and Programs Process ID and Parent Process ID Memory Layout of a Process Virtual Memory Management The Stack and Stack Frames Command-Line Arguments (argc, argv) Environment List Performing a Nonlocal Goto: setjmp() and longjmp() Summary Exercises xii TLPI_FINAL_RRD.pdf 12

3 7 MEMORY ALLOCATION Allocating Memory on the Heap Adjusting the Program Break: brk() and sbrk() Allocating Memory on the Heap: malloc() and free() Implementation of malloc() and free() Other Methods of Allocating Memory on the Heap Allocating Memory on the Stack: alloca() Summary Exercises USERS AND GROUPS The Password File: /etc/passwd The Shadow Password File: /etc/shadow The Group File: /etc/group Retrieving User and Group Information Password Encryption and User Authentication Summary Exercises PROCESS CREDENTIALS Real User ID and Real Group ID Effective User ID and Effective Group ID Set-User-ID and Set-Group-ID Programs Saved Set-User-ID and Saved Set-Group-ID File-System User ID and File-System Group ID Supplementary Group IDs Retrieving and Modifying Process Credentials Retrieving and Modifying Real, Effective, and Saved Set IDs Retrieving and Modifying File-System IDs Retrieving and Modifying Supplementary Group IDs Summary of Calls for Modifying Process Credentials Example: Displaying Process Credentials Summary Exercises TIME Calendar Time Time-Conversion Functions Converting time_t to Printable Form Converting Between time_t and Broken-Down Time Converting Between Broken-Down Time and Printable Form Timezones Locales Updating the System Clock The Software Clock (Jiffies) Process Time Summary Exercise xiii TLPI_FINAL_RRD.pdf 13

4 11 SYSTEM LIMITS AND OPTIONS System Limits Retrieving System Limits (and Options) at Run Time Retrieving File-Related Limits (and Options) at Run Time Indeterminate Limits System Options Summary Exercises SYSTEM AND PROCESS INFORMATION The /proc File System Obtaining Information About a Process: /proc/pid System Information Under /proc Accessing /proc Files System Identification: uname() Summary Exercises FILE I/O BUFFERING Kernel Buffering of File I/O: The Buffer Cache Buffering in the stdio Library Controlling Kernel Buffering of File I/O Summary of I/O Buffering Advising the Kernel About I/O Patterns Bypassing the Buffer Cache: Direct I/O Mixing Library Functions and System Calls for File I/O Summary Exercises FILE SYSTEMS Device Special Files (Devices) Disks and Partitions File Systems I-nodes The Virtual File System (VFS) Journaling File Systems Single Directory Hierarchy and Mount Points Mounting and Unmounting File Systems Mounting a File System: mount() Unmounting a File System: umount() and umount2() Advanced Mount Features Mounting a File System at Multiple Mount Points Stacking Multiple Mounts on the Same Mount Point Mount Flags That Are Per-Mount Options Bind Mounts Recursive Bind Mounts A Virtual Memory File System: tmpfs Obtaining Information About a File System: statvfs() Summary Exercise xiv TLPI_FINAL_RRD.pdf 14

5 15 FILE ATTRIBUTES Retrieving File Information: stat() File Timestamps Changing File Timestamps with utime() and utimes() Changing File Timestamps with utimensat() and futimens() File Ownership Ownership of New Files Changing File Ownership: chown(), fchown(), and lchown() File Permissions Permissions on Regular Files Permissions on Directories Permission-Checking Algorithm Checking File Accessibility: access() Set-User-ID, Set-Group-ID, and Sticky Bits The Process File Mode Creation Mask: umask() Changing File Permissions: chmod() and fchmod() I-node Flags (ext2 Extended File Attributes) Summary Exercises EXTENDED ATTRIBUTES Overview Extended Attribute Implementation Details System Calls for Manipulating Extended Attributes Summary Exercise ACCESS CONTROL LISTS Overview ACL Permission-Checking Algorithm Long and Short Text Forms for ACLs The ACL_MASK Entry and the ACL Group Class The getfacl and setfacl Commands Default ACLs and File Creation ACL Implementation Limits The ACL API Summary Exercise DIRECTORIES AND LINKS Directories and (Hard) Links Symbolic (Soft) Links Creating and Removing (Hard) Links: link() and unlink() Changing the Name of a File: rename() Working with Symbolic Links: symlink() and readlink() Creating and Removing Directories: mkdir() and rmdir() Removing a File or Directory: remove() Reading Directories: opendir() and readdir() File Tree Walking: nftw() The Current Working Directory of a Process Operating Relative to a Directory File Descriptor Changing the Root Directory of a Process: chroot() Resolving a Pathname: realpath() xv TLPI_FINAL_RRD.pdf 15

6 18.14 Parsing Pathname Strings: dirname() and basename() Summary Exercises MONITORING FILE EVENTS Overview The inotify API inotify Events Reading inotify Events Queue Limits and /proc Files An Older System for Monitoring File Events: dnotify Summary Exercise SIGNALS: FUNDAMENTAL CONCEPTS Concepts and Overview Signal Types and Default Actions Changing Signal Dispositions: signal() Introduction to Signal Handlers Sending Signals: kill() Checking for the Existence of a Process Other Ways of Sending Signals: raise() and killpg() Displaying Signal Descriptions Signal Sets The Signal Mask (Blocking Signal Delivery) Pending Signals Signals Are Not Queued Changing Signal Dispositions: sigaction() Waiting for a Signal: pause() Summary Exercises SIGNALS: SIGNAL HANDLERS Designing Signal Handlers Signals Are Not Queued (Revisited) Reentrant and Async-Signal-Safe Functions Global Variables and the sig_atomic_t Data Type Other Methods of Terminating a Signal Handler Performing a Nonlocal Goto from a Signal Handler Terminating a Process Abnormally: abort() Handling a Signal on an Alternate Stack: sigaltstack() The SA_SIGINFO Flag Interruption and Restarting of System Calls Summary Exercise SIGNALS: ADVANCED FEATURES Core Dump Files Special Cases for Delivery, Disposition, and Handling Interruptible and Uninterruptible Process Sleep States Hardware-Generated Signals Synchronous and Asynchronous Signal Generation xvi TLPI_FINAL_RRD.pdf 16

7 22.6 Timing and Order of Signal Delivery Implementation and Portability of signal() Realtime Signals Sending Realtime Signals Handling Realtime Signals Waiting for a Signal Using a Mask: sigsuspend() Synchronously Waiting for a Signal Fetching Signals via a File Descriptor Interprocess Communication with Signals Earlier Signal APIs (System V and BSD) Summary Exercises TIMERS AND SLEEPING Interval Timers Scheduling and Accuracy of Timers Setting Timeouts on Blocking Operations Suspending Execution for a Fixed Interval (Sleeping) Low-Resolution Sleeping: sleep() High-Resolution Sleeping: nanosleep() POSIX Clocks Retrieving the Value of a Clock: clock_gettime() Setting the Value of a Clock: clock_settime() Obtaining the Clock ID of a Specific Process or Thread Improved High-Resolution Sleeping: clock_nanosleep() POSIX Interval Timers Creating a Timer: timer_create() Arming and Disarming a Timer: timer_settime() Retrieving the Current Value of a Timer: timer_gettime() Deleting a Timer: timer_delete() Notification via a Signal Timer Overruns Notification via a Thread Timers That Notify via File Descriptors: the timerfd API Summary Exercises PROCESS CREATION Overview of fork(), exit(), wait(), and execve() Creating a New Process: fork() File Sharing Between Parent and Child Memory Semantics of fork() The vfork() System Call Race Conditions After fork() Avoiding Race Conditions by Synchronizing with Signals Summary Exercises PROCESS TERMINATION Terminating a Process: _exit() and exit() Details of Process Termination Exit Handlers Interactions Between fork(), stdio Buffers, and _exit() xvii TLPI_FINAL_RRD.pdf 17

8 25.5 Summary Exercise MONITORING CHILD PROCESSES Waiting on a Child Process The wait() System Call The waitpid() System Call The Wait Status Value Process Termination from a Signal Handler The waitid() System Call The wait3() and wait4() System Calls Orphans and Zombies The SIGCHLD Signal Establishing a Handler for SIGCHLD Delivery of SIGCHLD for Stopped Children Ignoring Dead Child Processes Summary Exercises PROGRAM EXECUTION Executing a New Program: execve() The exec() Library Functions The PATH Environment Variable Specifying Program Arguments as a List Passing the Caller s Environment to the New Program Executing a File Referred to by a Descriptor: fexecve() Interpreter Scripts File Descriptors and exec() Signals and exec() Executing a Shell Command: system() Implementing system() Summary Exercises PROCESS CREATION AND PROGRAM EXECUTION IN MORE DETAIL Process Accounting The clone() System Call The clone() flags Argument Extensions to waitpid() for Cloned Children Speed of Process Creation Effect of exec() and fork() on Process Attributes Summary Exercise THREADS: INTRODUCTION Overview Background Details of the Pthreads API Thread Creation Thread Termination Thread IDs Joining with a Terminated Thread Detaching a Thread xviii TLPI_FINAL_RRD.pdf 18

9 29.8 Thread Attributes Threads Versus Processes Summary Exercises THREADS: THREAD SYNCHRONIZATION Protecting Accesses to Shared Variables: Mutexes Statically Allocated Mutexes Locking and Unlocking a Mutex Performance of Mutexes Mutex Deadlocks Dynamically Initializing a Mutex Mutex Attributes Mutex Types Signaling Changes of State: Condition Variables Statically Allocated Condition Variables Signaling and Waiting on Condition Variables Testing a Condition Variable s Predicate Example Program: Joining Any Terminated Thread Dynamically Allocated Condition Variables Summary Exercises THREADS: THREAD SAFETY AND PER-THREAD STORAGE Thread Safety (and Reentrancy Revisited) One-Time Initialization Thread-Specific Data Thread-Specific Data from the Library Function s Perspective Overview of the Thread-Specific Data API Details of the Thread-Specific Data API Employing the Thread-Specific Data API Thread-Specific Data Implementation Limits Thread-Local Storage Summary Exercises THREADS: THREAD CANCELLATION Canceling a Thread Cancellation State and Type Cancellation Points Testing for Thread Cancellation Cleanup Handlers Asynchronous Cancelability Summary THREADS: FURTHER DETAILS Thread Stacks Threads and Signals How the UNIX Signal Model Maps to Threads Manipulating the Thread Signal Mask Sending a Signal to a Thread Dealing with Asynchronous Signals Sanely xix TLPI_FINAL_RRD.pdf 19

10 33.3 Threads and Process Control Thread Implementation Models Linux Implementations of POSIX Threads LinuxThreads NPTL Which Threading Implementation? Advanced Features of the Pthreads API Summary Exercises PROCESS GROUPS, SESSIONS, AND JOB CONTROL Overview Process Groups Sessions Controlling Terminals and Controlling Processes Foreground and Background Process Groups The SIGHUP Signal Handling of SIGHUP by the Shell SIGHUP and Termination of the Controlling Process Job Control Using Job Control Within the Shell Implementing Job Control Handling Job-Control Signals Orphaned Process Groups (and SIGHUP Revisited) Summary Exercises PROCESS PRIORITIES AND SCHEDULING Process Priorities (Nice Values) Overview of Realtime Process Scheduling The SCHED_RR Policy The SCHED_FIFO Policy The SCHED_BATCH and SCHED_IDLE Policies Realtime Process Scheduling API Realtime Priority Ranges Modifying and Retrieving Policies and Priorities Relinquishing the CPU The SCHED_RR Time Slice CPU Affinity Summary Exercises PROCESS RESOURCES Process Resource Usage Process Resource Limits Details of Specific Resource Limits Summary Exercises DAEMONS Overview Creating a Daemon xx TLPI_FINAL_RRD.pdf 20

11 37.3 Guidelines for Writing Daemons Using SIGHUP to Reinitialize a Daemon Logging Messages and Errors Using syslog Overview The syslog API The /etc/syslog.conf File Summary Exercise WRITING SECURE PRIVILEGED PROGRAMS Is a Set-User-ID or Set-Group-ID Program Required? Operate with Least Privilege Be Careful When Executing a Program Avoid Exposing Sensitive Information Confine the Process Beware of Signals and Race Conditions Pitfalls When Performing File Operations and File I/O Don t Trust Inputs or the Environment Beware of Buffer Overruns Beware of Denial-of-Service Attacks Check Return Statuses and Fail Safely Summary Exercises CAPABILITIES Rationale for Capabilities The Linux Capabilities Process and File Capabilities Process Capabilities File Capabilities Purpose of the Process Permitted and Effective Capability Sets Purpose of the File Permitted and Effective Capability Sets Purpose of the Process and File Inheritable Sets Assigning and Viewing File Capabilities from the Shell The Modern Capabilities Implementation Transformation of Process Capabilities During exec() Capability Bounding Set Preserving root Semantics Effect on Process Capabilities of Changing User IDs Changing Process Capabilities Programmatically Creating Capabilities-Only Environments Discovering the Capabilities Required by a Program Older Kernels and Systems Without File Capabilities Summary Exercise LOGIN ACCOUNTING Overview of the utmp and wtmp Files The utmpx API The utmpx Structure Retrieving Information from the utmp and wtmp Files Retrieving the Login Name: getlogin() Updating the utmp and wtmp Files for a Login Session xxi TLPI_FINAL_RRD.pdf 21

12 40.7 The lastlog File Summary Exercises FUNDAMENTALS OF SHARED LIBRARIES Object Libraries Static Libraries Overview of Shared Libraries Creating and Using Shared Libraries A First Pass Creating a Shared Library Position-Independent Code Using a Shared Library The Shared Library Soname Useful Tools for Working with Shared Libraries Shared Library Versions and Naming Conventions Installing Shared Libraries Compatible Versus Incompatible Libraries Upgrading Shared Libraries Specifying Library Search Directories in an Object File Finding Shared Libraries at Run Time Run-Time Symbol Resolution Using a Static Library Instead of a Shared Library Summary Exercise ADVANCED FEATURES OF SHARED LIBRARIES Dynamically Loaded Libraries Opening a Shared Library: dlopen() Diagnosing Errors: dlerror() Obtaining the Address of a Symbol: dlsym() Closing a Shared Library: dlclose() Obtaining Information About Loaded Symbols: dladdr() Accessing Symbols in the Main Program Controlling Symbol Visibility Linker Version Scripts Controlling Symbol Visibility with Version Scripts Symbol Versioning Initialization and Finalization Functions Preloading Shared Libraries Monitoring the Dynamic Linker: LD_DEBUG Summary Exercises INTERPROCESS COMMUNICATION OVERVIEW A Taxonomy of IPC Facilities Communication Facilities Synchronization Facilities Comparing IPC Facilities Summary Exercises xxii TLPI_FINAL_RRD.pdf 22

13 44 PIPES AND FIFOS Overview Creating and Using Pipes Pipes as a Method of Process Synchronization Using Pipes to Connect Filters Talking to a Shell Command via a Pipe: popen() Pipes and stdio Buffering FIFOs A Client-Server Application Using FIFOs Nonblocking I/O Semantics of read() and write() on Pipes and FIFOs Summary Exercises INTRODUCTION TO SYSTEM V IPC API Overview IPC Keys Associated Data Structure and Object Permissions IPC Identifiers and Client-Server Applications Algorithm Employed by System V IPC get Calls The ipcs and ipcrm Commands Obtaining a List of All IPC Objects IPC Limits Summary Exercises SYSTEM V MESSAGE QUEUES Creating or Opening a Message Queue Exchanging Messages Sending Messages Receiving Messages Message Queue Control Operations Message Queue Associated Data Structure Message Queue Limits Displaying All Message Queues on the System Client-Server Programming with Message Queues A File-Server Application Using Message Queues Disadvantages of System V Message Queues Summary Exercises SYSTEM V SEMAPHORES Overview Creating or Opening a Semaphore Set Semaphore Control Operations Semaphore Associated Data Structure Semaphore Initialization Semaphore Operations Handling of Multiple Blocked Semaphore Operations Semaphore Undo Values Implementing a Binary Semaphores Protocol xxiii TLPI_FINAL_RRD.pdf 23

14 47.10 Semaphore Limits Disadvantages of System V Semaphores Summary Exercises SYSTEM V SHARED MEMORY Overview Creating or Opening a Shared Memory Segment Using Shared Memory Example: Transferring Data via Shared Memory Location of Shared Memory in Virtual Memory Storing Pointers in Shared Memory Shared Memory Control Operations Shared Memory Associated Data Structure Shared Memory Limits Summary Exercises MEMORY MAPPINGS Overview Creating a Mapping: mmap() Unmapping a Mapped Region: munmap() File Mappings Private File Mappings Shared File Mappings Boundary Cases Memory Protection and File Access Mode Interactions Synchronizing a Mapped Region: msync() Additional mmap() Flags Anonymous Mappings Remapping a Mapped Region: mremap() MAP_NORESERVE and Swap Space Overcommitting The MAP_FIXED Flag Nonlinear Mappings: remap_file_pages() Summary Exercises VIRTUAL MEMORY OPERATIONS Changing Memory Protection: mprotect() Memory Locking: mlock() and mlockall() Determining Memory Residence: mincore() Advising Future Memory Usage Patterns: madvise() Summary Exercises INTRODUCTION TO POSIX IPC API Overview Comparison of System V IPC and POSIX IPC Summary xxiv TLPI_FINAL_RRD.pdf 24

15 52 POSIX MESSAGE QUEUES Overview Opening, Closing, and Unlinking a Message Queue Relationship Between Descriptors and Message Queues Message Queue Attributes Exchanging Messages Sending Messages Receiving Messages Sending and Receiving Messages with a Timeout Message Notification Receiving Notification via a Signal Receiving Notification via a Thread Linux-Specific Features Message Queue Limits Comparison of POSIX and System V Message Queues Summary Exercises POSIX SEMAPHORES Overview Named Semaphores Opening a Named Semaphore Closing a Semaphore Removing a Named Semaphore Semaphore Operations Waiting on a Semaphore Posting a Semaphore Retrieving the Current Value of a Semaphore Unnamed Semaphores Initializing an Unnamed Semaphore Destroying an Unnamed Semaphore Comparisons with Other Synchronization Techniques Semaphore Limits Summary Exercises POSIX SHARED MEMORY Overview Creating Shared Memory Objects Using Shared Memory Objects Removing Shared Memory Objects Comparisons Between Shared Memory APIs Summary Exercise FILE LOCKING Overview File Locking with flock() Semantics of Lock Inheritance and Release Limitations of flock() xxv TLPI_FINAL_RRD.pdf 25 8/5/ :46:57 AM

16 55.3 Record Locking with fcntl() Deadlock Example: An Interactive Locking Program Example: A Library of Locking Functions Lock Limits and Performance Semantics of Lock Inheritance and Release Lock Starvation and Priority of Queued Lock Requests Mandatory Locking The /proc/locks File Running Just One Instance of a Program Older Locking Techniques Summary Exercises SOCKETS: INTRODUCTION Overview Creating a Socket: socket() Binding a Socket to an Address: bind() Generic Socket Address Structures: struct sockaddr Stream Sockets Listening for Incoming Connections: listen() Accepting a Connection: accept() Connecting to a Peer Socket: connect() I/O on Stream Sockets Connection Termination: close() Datagram Sockets Exchanging Datagrams: recvfrom() and sendto() Using connect() with Datagram Sockets Summary SOCKETS: UNIX DOMAIN UNIX Domain Socket Addresses: struct sockaddr_un Stream Sockets in the UNIX Domain Datagram Sockets in the UNIX Domain UNIX Domain Socket Permissions Creating a Connected Socket Pair: socketpair() The Linux Abstract Socket Namespace Summary Exercises SOCKETS: FUNDAMENTALS OF TCP/IP NETWORKS Internets Networking Protocols and Layers The Data-Link Layer The Network Layer: IP IP Addresses The Transport Layer Port Numbers User Datagram Protocol (UDP) Transmission Control Protocol (TCP) Requests for Comments (RFCs) Summary xxvi TLPI_FINAL_RRD.pdf 26 8/5/ :46:57 AM

17 59 SOCKETS: INTERNET DOMAINS Internet Domain Sockets Network Byte Order Data Representation Internet Socket Addresses Overview of Host and Service Conversion Functions The inet_pton() and inet_ntop() Functions Client-Server Example (Datagram Sockets) Domain Name System (DNS) The /etc/services File Protocol-Independent Host and Service Conversion The getaddrinfo() Function Freeing addrinfo Lists: freeaddrinfo() Diagnosing Errors: gai_strerror() The getnameinfo() Function Client-Server Example (Stream Sockets) An Internet Domain Sockets Library Obsolete APIs for Host and Service Conversions The inet_aton() and inet_ntoa() Functions The gethostbyname() and gethostbyaddr() Functions The getservbyname() and getservbyport() Functions UNIX Versus Internet Domain Sockets Further Information Summary Exercises SOCKETS: SERVER DESIGN Iterative and Concurrent Servers An Iterative UDP echo Server A Concurrent TCP echo Server Other Concurrent Server Designs The inetd (Internet Superserver) Daemon Summary Exercises SOCKETS: ADVANCED TOPICS Partial Reads and Writes on Stream Sockets The shutdown() System Call Socket-Specific I/O System Calls: recv() and send() The sendfile() System Call Retrieving Socket Addresses A Closer Look at TCP Format of a TCP Segment TCP Sequence Numbers and Acknowledgements TCP State Machine and State Transition Diagram TCP Connection Establishment TCP Connection Termination Calling shutdown() on a TCP Socket The TIME_WAIT State Monitoring Sockets: netstat Using tcpdump to Monitor TCP Traffic Socket Options The SO_REUSEADDR Socket Option Inheritance of Flags and Options Across accept() xxvii TLPI_FINAL_RRD.pdf 27 8/5/ :46:57 AM

18 61.12 TCP Versus UDP Advanced Features Out-of-Band Data The sendmsg() and recvmsg() System Calls Passing File Descriptors Receiving Sender Credentials Sequenced-Packet Sockets SCTP and DCCP Transport-Layer Protocols Summary Exercises TERMINALS Overview Retrieving and Modifying Terminal Attributes The stty Command Terminal Special Characters Terminal Flags Terminal I/O Modes Canonical Mode Noncanonical Mode Cooked, Cbreak, and Raw Modes Terminal Line Speed (Bit Rate) Terminal Line Control Terminal Window Size Terminal Identification Summary Exercises ALTERNATIVE I/O MODELS Overview Level-Triggered and Edge-Triggered Notification Employing Nonblocking I/O with Alternative I/O Models I/O Multiplexing The select() System Call The poll() System Call When Is a File Descriptor Ready? Comparison of select() and poll() Problems with select() and poll() Signal-Driven I/O When Is I/O Possible Signaled? Refining the Use of Signal-Driven I/O The epoll API Creating an epoll Instance: epoll_create() Modifying the epoll Interest List: epoll_ctl() Waiting for Events: epoll_wait() A Closer Look at epoll Semantics Performance of epoll Versus I/O Multiplexing Edge-Triggered Notification Waiting on Signals and File Descriptors The pselect() System Call The Self-Pipe Trick Summary Exercises xxviii TLPI_FINAL_RRD.pdf 28 8/5/ :46:57 AM

19 64 PSEUDOTERMINALS Overview UNIX 98 Pseudoterminals Opening an Unused Master: posix_openpt() Changing Slave Ownership and Permissions: grantpt() Unlocking the Slave: unlockpt() Obtaining the Name of the Slave: ptsname() Opening a Master: ptymasteropen() Connecting Processes with a Pseudoterminal: ptyfork() Pseudoterminal I/O Implementing script(1) Terminal Attributes and Window Size BSD Pseudoterminals Summary Exercises A TRACING SYSTEM CALLS 1401 B PARSING COMMAND-LINE OPTIONS 1405 C CASTING THE NULL POINTER 1413 D KERNEL CONFIGURATION 1417 E FURTHER SOURCES OF INFORMATION 1419 F SOLUTIONS TO SELECTED EXERCISES 1425 BIBLIOGRAPHY 1437 INDEX 1447 xxix TLPI_FINAL_RRD.pdf 29 8/5/ :46:57 AM

Advanced Programming in the UNIX Environment W. Richard Stevens

Advanced Programming in the UNIX Environment W. Richard Stevens Advanced Programming in the UNIX Environment W. Richard Stevens ADDISON-WESLEY PUBLISHING COMPANY Reading, Massachusetts Menlo Park, California New York Don Mills, Ontario Wokingham, England Amsterdam

More information

Contents. Part 1. Introduction and TCP/IP 1. Foreword Preface. xix. I ntroduction 31

Contents. Part 1. Introduction and TCP/IP 1. Foreword Preface. xix. I ntroduction 31 Foreword Preface Xvii xix Part 1. Introduction and TCP/IP 1 Chapter 1. 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 1.10 1.11 1.12 Chapter 2. 2.1 2.2 2.3 I ntroduction I ntroduction 3 A Simple Daytime Client 6

More information

CHETTINAD COLLEGE OF ENGINEERING AND TECHNOLOGY DEPARTMENT OF MCA QUESTION BANK UNIT 1

CHETTINAD COLLEGE OF ENGINEERING AND TECHNOLOGY DEPARTMENT OF MCA QUESTION BANK UNIT 1 CHETTINAD COLLEGE OF ENGINEERING AND TECHNOLOGY DEPARTMENT OF MCA QUESTION BANK SUBJECT: NETWORK PROGRAMMING/MC9241 YEAR/ SEM: II /I V 1 CCET UNIT 1 1. What are the steps involved in obtaining a shared

More information

UNIX Network Programming

UNIX Network Programming UNIX Network Programming The Sockets Networking API Volume 1 Third Edition W. Richard Stevens Bill Fenner Andrew M. Rudoff AAddison-Wesley Boston San Francisco New York Toronto Montreal London Munich Paris

More information

Overview. Over the next four weeks, we will look at these topics: Building Blocks. Advanced Authentication Issues.

Overview. Over the next four weeks, we will look at these topics: Building Blocks. Advanced Authentication Issues. Overview Over the next four weeks, we will look at these topics: Building Blocks Advanced Authentication Issues Security Overview Storage and its abstraction Virtualization and appliances Data Replication

More information

UNIT I Linux Utilities

UNIT I Linux Utilities UNIT I Linux Utilities 1. a) How does Linux differ from Unix? Discuss the features of Linux. 5M b) Explain various text processing utilities, with a suitable example for each. 5M 2. a) Explain briefly

More information

VALLIAMMAI ENGINEERING COLLEGE. SRM Nagar, Kattankulathur QUESTION BANK

VALLIAMMAI ENGINEERING COLLEGE. SRM Nagar, Kattankulathur QUESTION BANK SRM Nagar, Kattankulathur 603 203 IV SEMESTER MC7404 NETWORK PROGRAMMING Regulation 2013 Academic Year 2017 18 Prepared by Mr. M.Asan Nainar, Assistant Professor/MCA UNIT I - INTRODUCTION Overview of UNIX

More information

St. MARTIN S ENGINEERING COLLEGE Dhulapally,Secunderabad DEPARTMENT OF INFORMATION TECHNOLOGY Academic year

St. MARTIN S ENGINEERING COLLEGE Dhulapally,Secunderabad DEPARTMENT OF INFORMATION TECHNOLOGY Academic year St. MARTIN S ENGINEERING COLLEGE Dhulapally,Secunderabad-000 DEPARTMENT OF INFORMATION TECHNOLOGY Academic year 0-0 QUESTION BANK Course Name : LINUX PROGRAMMING Course Code : A0 Class : III B. Tech I

More information

Building blocks for Unix power tools

Building blocks for Unix power tools for Unix power tools Now that we have given a good overview of a lot of the better Unix tools, I want to take some time to talk about our toolset for building Unix programs. The most important of these

More information

Linux Driver and Embedded Developer

Linux Driver and Embedded Developer Linux Driver and Embedded Developer Course Highlights The flagship training program from Veda Solutions, successfully being conducted from the past 10 years A comprehensive expert level course covering

More information

Contents. Volume 1 Base Definitions, Issue

Contents. Volume 1 Base Definitions, Issue Volume 1 Base Definitions, Issue 7... 1 Chapter 1 Introduction... 3 1.1 Scope... 3 1.2 Conformance... 4 1.3 Normative References... 4 1.4 Change History... 5 1.5 Terminology... 5 1.6 Definitions and Concepts...

More information

CL020 - Advanced Linux and UNIX Programming

CL020 - Advanced Linux and UNIX Programming Corder Enterprises International Building World Class MIS Teams, for you! CL020 - Advanced Linux and UNIX Programming Course Description: In-depth training for software developers on Linux and UNIX system

More information

INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad

INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad -500 043 COMPUTER SCIENCE AND ENGINEERING TUTORIAL QUESTION BANK Course Name : LINUX PROGRAMMING Course Code : ACS010 Class : III

More information

Noorul Islam College Of Engineering, Kumaracoil MCA Degree Model Examination (October 2007) 5 th Semester MC1642 UNIX Internals 2 mark Questions

Noorul Islam College Of Engineering, Kumaracoil MCA Degree Model Examination (October 2007) 5 th Semester MC1642 UNIX Internals 2 mark Questions Noorul Islam College Of Engineering, Kumaracoil MCA Degree Model Examination (October 2007) 5 th Semester MC1642 UNIX Internals 2 mark Questions 1. What are the different parts of UNIX system? i. Programs

More information

Design Overview of the FreeBSD Kernel CIS 657

Design Overview of the FreeBSD Kernel CIS 657 Design Overview of the FreeBSD Kernel CIS 657 Organization of the Kernel Machine-independent 86% of the kernel (80% in 4.4BSD) C code Machine-dependent 14% of kernel Only 0.6% of kernel in assembler (2%

More information

UNIT I Linux Utilities and Working with Bash

UNIT I Linux Utilities and Working with Bash Subject with Code :(16MC814)Course& Branch: MCA Year & Sem: II-MCA& I-Sem UNIT I Linux Utilities and Working with Bash 1. a) How does Linux differ from Unix? Discuss the features of Linux.6M b) Explain

More information

LINUX INTERNALS & NETWORKING Weekend Workshop

LINUX INTERNALS & NETWORKING Weekend Workshop Here to take you beyond LINUX INTERNALS & NETWORKING Weekend Workshop Linux Internals & Networking Weekend workshop Objectives: To get you started with writing system programs in Linux Build deeper view

More information

Design Overview of the FreeBSD Kernel. Organization of the Kernel. What Code is Machine Independent?

Design Overview of the FreeBSD Kernel. Organization of the Kernel. What Code is Machine Independent? Design Overview of the FreeBSD Kernel CIS 657 Organization of the Kernel Machine-independent 86% of the kernel (80% in 4.4BSD) C C code Machine-dependent 14% of kernel Only 0.6% of kernel in assembler

More information

Linux Kernel Architecture

Linux Kernel Architecture Professional Linux Kernel Architecture Wolf gang Mauerer WILEY Wiley Publishing, Inc. Introduction xxvii Chapter 1: Introduction and Overview 1 Tasks of the Kernel v -- 2 Implementation Strategies 3 Elements

More information

PROCESS CONCEPTS. Process Concept Relationship to a Program What is a Process? Process Lifecycle Process Management Inter-Process Communication 2.

PROCESS CONCEPTS. Process Concept Relationship to a Program What is a Process? Process Lifecycle Process Management Inter-Process Communication 2. [03] PROCESSES 1. 1 OUTLINE Process Concept Relationship to a Program What is a Process? Process Lifecycle Creation Termination Blocking Process Management Process Control Blocks Context Switching Threads

More information

Overview. Last Lecture. This Lecture. Daemon processes and advanced I/O functions

Overview. Last Lecture. This Lecture. Daemon processes and advanced I/O functions Overview Last Lecture Daemon processes and advanced I/O functions This Lecture Unix domain protocols and non-blocking I/O Source: Chapters 15&16&17 of Stevens book Unix domain sockets A way of performing

More information

NETWORK PROGRAMMING AND MANAGEMENT 1 KINGS DEPARTMENT OF INFORMATION TECHNOLOGY QUESTION BANK

NETWORK PROGRAMMING AND MANAGEMENT 1 KINGS DEPARTMENT OF INFORMATION TECHNOLOGY QUESTION BANK NETWORK PROGRAMMING AND MANAGEMENT 1 KINGS COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY QUESTION BANK Subject Code & Name: Network Programming and Management Year / Sem : III / VI UNIT-

More information

Memory-Mapped Files. generic interface: vaddr mmap(file descriptor,fileoffset,length) munmap(vaddr,length)

Memory-Mapped Files. generic interface: vaddr mmap(file descriptor,fileoffset,length) munmap(vaddr,length) File Systems 38 Memory-Mapped Files generic interface: vaddr mmap(file descriptor,fileoffset,length) munmap(vaddr,length) mmap call returns the virtual address to which the file is mapped munmap call unmaps

More information

Motivation of VPN! Overview! VPN addressing and routing! Two basic techniques for VPN! ! How to guarantee privacy of network traffic?!

Motivation of VPN! Overview! VPN addressing and routing! Two basic techniques for VPN! ! How to guarantee privacy of network traffic?! Overview!! Last Lecture!! Daemon processes and advanced I/O functions!! This Lecture!! VPN, NAT, DHCP!! Source: Chapters 19&22 of Comer s book!! Unix domain protocols and non-blocking I/O!! Source: Chapters

More information

INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad

INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad -500 043 COMPUTER SCIENCE AND ENGINEERING TUTORIAL QUESTION BANK Course Name : LINUX PROGRAMMING Course Code : A70511 (R15) Class

More information

Computer Systems A Programmer s Perspective 1 (Beta Draft)

Computer Systems A Programmer s Perspective 1 (Beta Draft) Computer Systems A Programmer s Perspective 1 (Beta Draft) Randal E. Bryant David R. O Hallaron August 1, 2001 1 Copyright c 2001, R. E. Bryant, D. R. O Hallaron. All rights reserved. 2 Contents Preface

More information

Chapter 8: I/O functions & socket options

Chapter 8: I/O functions & socket options Chapter 8: I/O functions & socket options 8.1 Introduction I/O Models In general, there are normally two phases for an input operation: 1) Waiting for the data to arrive on the network. When the packet

More information

Shell Execution of Programs. Process Groups, Session and Signals 1

Shell Execution of Programs. Process Groups, Session and Signals 1 Shell Execution of Programs Process Groups, Session and Signals 1 Signal Concepts Signals are a way for a process to be notified of asynchronous events (software interrupts). Some examples: a timer you

More information

ECE 550D Fundamentals of Computer Systems and Engineering. Fall 2017

ECE 550D Fundamentals of Computer Systems and Engineering. Fall 2017 ECE 550D Fundamentals of Computer Systems and Engineering Fall 2017 The Operating System (OS) Prof. John Board Duke University Slides are derived from work by Profs. Tyler Bletsch and Andrew Hilton (Duke)

More information

Operating Systems. II. Processes

Operating Systems. II. Processes Operating Systems II. Processes Ludovic Apvrille ludovic.apvrille@telecom-paristech.fr Eurecom, office 470 http://soc.eurecom.fr/os/ @OS Eurecom Outline Concepts Definitions and basic concepts Process

More information

Kernel Internals. Course Duration: 5 days. Pre-Requisites : Course Objective: Course Outline

Kernel Internals. Course Duration: 5 days. Pre-Requisites : Course Objective: Course Outline Course Duration: 5 days Pre-Requisites : Good C programming skills. Required knowledge Linux as a User Course Objective: To get Kernel and User Space of Linux and related programming Linux Advance Programming

More information

CSC209 Review. Yeah! We made it!

CSC209 Review. Yeah! We made it! CSC209 Review Yeah! We made it! 1 CSC209: Software tools Unix files and directories permissions utilities/commands Shell programming quoting wild cards files 2 ... and C programming... C basic syntax functions

More information

VEOS high level design. Revision 2.1 NEC

VEOS high level design. Revision 2.1 NEC high level design Revision 2.1 NEC Table of contents About this document What is Components Process management Memory management System call Signal User mode DMA and communication register Feature list

More information

INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad

INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad -500 043 COMPUTER SCIENCE AND ENGINEERING TUTORIAL QUESTION BANK Course Name : LINUX PROGRAMMING Course Code : A70511 Class : IV B.

More information

Department of Computer Science and Technology, UTU 2014

Department of Computer Science and Technology, UTU 2014 Short Questions 060010601 Unix Internals Unit 1 : Introduction and Overview of UNIX 1. What were the goals of Multics System? 2. List out the levels in which UNIX system architecture is divided. 3. Which

More information

PROCESS MANAGEMENT. Operating Systems 2015 Spring by Euiseong Seo

PROCESS MANAGEMENT. Operating Systems 2015 Spring by Euiseong Seo PROCESS MANAGEMENT Operating Systems 2015 Spring by Euiseong Seo Today s Topics Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication

More information

PROCESS CONTROL BLOCK TWO-STATE MODEL (CONT D)

PROCESS CONTROL BLOCK TWO-STATE MODEL (CONT D) MANAGEMENT OF APPLICATION EXECUTION PROCESS CONTROL BLOCK Resources (processor, I/O devices, etc.) are made available to multiple applications The processor in particular is switched among multiple applications

More information

CSC209: Software tools. Unix files and directories permissions utilities/commands Shell programming quoting wild cards files

CSC209: Software tools. Unix files and directories permissions utilities/commands Shell programming quoting wild cards files CSC209 Review CSC209: Software tools Unix files and directories permissions utilities/commands Shell programming quoting wild cards files ... and systems programming C basic syntax functions arrays structs

More information

CSC209: Software tools. Unix files and directories permissions utilities/commands Shell programming quoting wild cards files. Compiler vs.

CSC209: Software tools. Unix files and directories permissions utilities/commands Shell programming quoting wild cards files. Compiler vs. CSC209 Review CSC209: Software tools Unix files and directories permissions utilities/commands Shell programming quoting wild cards files... and systems programming C basic syntax functions arrays structs

More information

Interprocess Communication Mechanisms

Interprocess Communication Mechanisms Interprocess Communication 1 Interprocess Communication Mechanisms shared storage These mechanisms have already been covered. examples: shared virtual memory shared files processes must agree on a name

More information

shared storage These mechanisms have already been covered. examples: shared virtual memory message based signals

shared storage These mechanisms have already been covered. examples: shared virtual memory message based signals Interprocess Communication 1 Interprocess Communication Mechanisms shared storage These mechanisms have already been covered. examples: shared virtual memory shared files processes must agree on a name

More information

3.1 Introduction. Computers perform operations concurrently

3.1 Introduction. Computers perform operations concurrently PROCESS CONCEPTS 1 3.1 Introduction Computers perform operations concurrently For example, compiling a program, sending a file to a printer, rendering a Web page, playing music and receiving e-mail Processes

More information

Programming with POSIX Threads

Programming with POSIX Threads Programming with POSIX Threads David R. Butenhof :vaddison-wesley Boston San Francisco New York Toronto Montreal London Munich Paris Madrid Capetown Sidney Tokyo Singapore Mexico City Contents List of

More information

ECE 574 Cluster Computing Lecture 8

ECE 574 Cluster Computing Lecture 8 ECE 574 Cluster Computing Lecture 8 Vince Weaver http://web.eece.maine.edu/~vweaver vincent.weaver@maine.edu 16 February 2017 Announcements Too many snow days Posted a video with HW#4 Review HW#5 will

More information

Chap 4, 5: Process. Dongkun Shin, SKKU

Chap 4, 5: Process. Dongkun Shin, SKKU Chap 4, 5: Process 1 Process Concept Job A bundle of program and data to be executed An entity before submission for execution Process (= running program) An entity that is registered to kernel for execution

More information

Reading Assignment 4. n Chapter 4 Threads, due 2/7. 1/31/13 CSE325 - Processes 1

Reading Assignment 4. n Chapter 4 Threads, due 2/7. 1/31/13 CSE325 - Processes 1 Reading Assignment 4 Chapter 4 Threads, due 2/7 1/31/13 CSE325 - Processes 1 What s Next? 1. Process Concept 2. Process Manager Responsibilities 3. Operations on Processes 4. Process Scheduling 5. Cooperating

More information

Process Concepts. CSC400 - Operating Systems. 3. Process Concepts. J. Sumey

Process Concepts. CSC400 - Operating Systems. 3. Process Concepts. J. Sumey CSC400 - Operating Systems 3. Process Concepts J. Sumey Overview Concurrency Processes & Process States Process Accounting Interrupts & Interrupt Processing Interprocess Communication CSC400 - Process

More information

Dr. Rafiq Zakaria Campus. Maulana Azad College of Arts, Science & Commerce, Aurangabad. Department of Computer Science. Academic Year

Dr. Rafiq Zakaria Campus. Maulana Azad College of Arts, Science & Commerce, Aurangabad. Department of Computer Science. Academic Year Dr. Rafiq Zakaria Campus Maulana Azad College of Arts, Science & Commerce, Aurangabad Department of Computer Science Academic Year 2015-16 MCQs on Operating System Sem.-II 1.What is operating system? a)

More information

History of FreeBSD. FreeBSD Kernel Facilities

History of FreeBSD. FreeBSD Kernel Facilities History of FreeBSD FreeBSD Kernel Facilities 1979 3BSD Added virtual memory to UNIX/32V 1981 4.1BSD 1983 4.2BSD Final release from Berkeley DARPA UNIX project 1986 4.3BSD 1988 4.3BSD Tahoe 1989 4.3BSD

More information

Chp1 Introduction. Introduction. Objective. Logging In. Shell. Briefly describe services provided by various versions of the UNIX operating system.

Chp1 Introduction. Introduction. Objective. Logging In. Shell. Briefly describe services provided by various versions of the UNIX operating system. Chp1 Objective Briefly describe services provided by various versions of the UNIX operating system. Logging In /etc/passwd local machine or NIS DB root:x:0:1:super-user:/root:/bin/tcsh Login-name, encrypted

More information

Chapter 3: Process Concept

Chapter 3: Process Concept Chapter 3: Process Concept Chapter 3: Process Concept Process Concept Process Scheduling Operations on Processes Inter-Process Communication (IPC) Communication in Client-Server Systems Objectives 3.2

More information

Chapter 3: Process Concept

Chapter 3: Process Concept Chapter 3: Process Concept Chapter 3: Process Concept Process Concept Process Scheduling Operations on Processes Inter-Process Communication (IPC) Communication in Client-Server Systems Objectives 3.2

More information

Last class: Today: Thread Background. Thread Systems

Last class: Today: Thread Background. Thread Systems 1 Last class: Thread Background Today: Thread Systems 2 Threading Systems 3 What kind of problems would you solve with threads? Imagine you are building a web server You could allocate a pool of threads,

More information

(In columns, of course.)

(In columns, of course.) CPS 310 first midterm exam, 10/9/2013 Your name please: Part 1. Fun with forks (a) What is the output generated by this program? In fact the output is not uniquely defined, i.e., it is not always the same.

More information

Processes. Dr. Yingwu Zhu

Processes. Dr. Yingwu Zhu Processes Dr. Yingwu Zhu Process Growing Memory Stack expands automatically Data area (heap) can grow via a system call that requests more memory - malloc() in c/c++ Entering the kernel (mode) Hardware

More information

Chapter 3: Process Concept

Chapter 3: Process Concept Chapter 3: Process Concept Silberschatz, Galvin and Gagne 2013! Chapter 3: Process Concept Process Concept" Process Scheduling" Operations on Processes" Inter-Process Communication (IPC)" Communication

More information

Secure Software Programming and Vulnerability Analysis

Secure Software Programming and Vulnerability Analysis Secure Software Programming and Vulnerability Analysis Christopher Kruegel chris@auto.tuwien.ac.at http://www.auto.tuwien.ac.at/~chris Race Conditions Secure Software Programming 2 Overview Parallel execution

More information

Linux Operating System

Linux Operating System Linux Operating System Dept. of Computer Science & Engineering 1 History Linux is a modern, free operating system based on UNIX standards. First developed as a small but self-contained kernel in 1991 by

More information

Lecture 15: I/O Devices & Drivers

Lecture 15: I/O Devices & Drivers CS 422/522 Design & Implementation of Operating Systems Lecture 15: I/O Devices & Drivers Zhong Shao Dept. of Computer Science Yale University Acknowledgement: some slides are taken from previous versions

More information

Software Development & Education Center

Software Development & Education Center Software Development & Education Center Embedded Linux & RTOS With ARM 9 µc Embedded Linux and RTOS with ARM9 µc Introduction The course is designed for those who want to pursue Linux based Embedded Systems.

More information

Files and Directories

Files and Directories Files and Directories Stat functions Given pathname, stat function returns structure of information about file fstat function obtains information about the file that is already open lstat same as stat

More information

Lecture 10 Overview!

Lecture 10 Overview! Lecture 10 Overview! Last Lecture! Wireless Sensor Networks! This Lecture! Daemon processes and advanced I/O functions! Source: Chapters 13 &14 of Stevens book! Next Lecture! Unix domain protocols and

More information

Module A: The FreeBSD System

Module A: The FreeBSD System Module A: The FreeBSD System History Design Principles Programmer Interface User Interface Process Management Memory Management File System I/O System Interprocess Communication A.1 History First developed

More information

Module A: The FreeBSD System

Module A: The FreeBSD System Module A: The FreeBSD System History Design Principles Programmer Interface User Interface Process Management Memory Management File System I/O System Interprocess Communication A.1 History First developed

More information

Contents in Detail. Acknowledgments

Contents in Detail. Acknowledgments Acknowledgments xix Introduction What s in This Book... xxii What Is Ethical Hacking?... xxiii Penetration Testing... xxiii Military and Espionage... xxiii Why Hackers Use Linux... xxiv Linux Is Open Source....

More information

Processes and Threads

Processes and Threads Process Processes and Threads A process is an abstraction that represent an executing program A program in execution An instance of a program running on a computer The entity that can be assigned to and

More information

Like select() and poll(), epoll can monitor multiple FDs epoll returns readiness information in similar manner to poll() Two main advantages:

Like select() and poll(), epoll can monitor multiple FDs epoll returns readiness information in similar manner to poll() Two main advantages: Outline 22 Alternative I/O Models 22-1 22.1 Overview 22-3 22.2 Nonblocking I/O 22-5 22.3 Signal-driven I/O 22-11 22.4 I/O multiplexing: poll() 22-14 22.5 Problems with poll() and select() 22-31 22.6 The

More information

Overview. Daemon processes and advanced I/O. Source: Chapters 13&14 of Stevens book

Overview. Daemon processes and advanced I/O. Source: Chapters 13&14 of Stevens book Overview Last Lecture Broadcast and multicast This Lecture Daemon processes and advanced I/O functions Source: Chapters 13&14 of Stevens book Next Lecture Unix domain protocols and non-blocking I/O Source:

More information

Lecture 8: Other IPC Mechanisms. CSC 469H1F Fall 2006 Angela Demke Brown

Lecture 8: Other IPC Mechanisms. CSC 469H1F Fall 2006 Angela Demke Brown Lecture 8: Other IPC Mechanisms CSC 469H1F Fall 2006 Angela Demke Brown Topics Messages through sockets / pipes Receiving notification of activity Generalizing the event notification mechanism Kqueue Semaphores

More information

Virtual File System. Don Porter CSE 306

Virtual File System. Don Porter CSE 306 Virtual File System Don Porter CSE 306 History Early OSes provided a single file system In general, system was pretty tailored to target hardware In the early 80s, people became interested in supporting

More information

Topics. Lecture 8: Other IPC Mechanisms. Socket IPC. Unix Communication

Topics. Lecture 8: Other IPC Mechanisms. Socket IPC. Unix Communication Topics Lecture 8: Other IPC Mechanisms CSC 469H1F Fall 2006 Angela Demke Brown Messages through sockets / pipes Receiving notification of activity Generalizing the event notification mechanism Kqueue Semaphores

More information

* What are the different states for a task in an OS?

* What are the different states for a task in an OS? * Kernel, Services, Libraries, Application: define the 4 terms, and their roles. The kernel is a computer program that manages input/output requests from software, and translates them into data processing

More information

(MCQZ-CS604 Operating Systems)

(MCQZ-CS604 Operating Systems) command to resume the execution of a suspended job in the foreground fg (Page 68) bg jobs kill commands in Linux is used to copy file is cp (Page 30) mv mkdir The process id returned to the child process

More information

Light & NOS. Dan Li Tsinghua University

Light & NOS. Dan Li Tsinghua University Light & NOS Dan Li Tsinghua University Performance gain The Power of DPDK As claimed: 80 CPU cycles per packet Significant gain compared with Kernel! What we care more How to leverage the performance gain

More information

CSE506: Operating Systems CSE 506: Operating Systems

CSE506: Operating Systems CSE 506: Operating Systems CSE 506: Operating Systems What Software Expects of the OS What Software Expects of the OS Shell Memory Address Space for Process System Calls System Services Launching Program Executables Shell Gives

More information

Windows 7 Overview. Windows 7. Objectives. The History of Windows. CS140M Fall Lake 1

Windows 7 Overview. Windows 7. Objectives. The History of Windows. CS140M Fall Lake 1 Windows 7 Overview Windows 7 Overview By Al Lake History Design Principles System Components Environmental Subsystems File system Networking Programmer Interface Lake 2 Objectives To explore the principles

More information

Announcement. Exercise #2 will be out today. Due date is next Monday

Announcement. Exercise #2 will be out today. Due date is next Monday Announcement Exercise #2 will be out today Due date is next Monday Major OS Developments 2 Evolution of Operating Systems Generations include: Serial Processing Simple Batch Systems Multiprogrammed Batch

More information

The Design and Implementation of the 4.4BSD Operating System. Marshall Kirk McKusick Keith Bostic Michael J. Karels John S.

The Design and Implementation of the 4.4BSD Operating System. Marshall Kirk McKusick Keith Bostic Michael J. Karels John S. The Design and Implementation of the 4.4BSD Operating System Marshall Kirk McKusick Keith Bostic Michael J. Karels John S. Quarterman The Design and Implementation of the 4.4BSD Operating System by Marshall

More information

Open System Services. Developer's Tips. Marc Fuentes and Milind Dattawadkar

Open System Services. Developer's Tips. Marc Fuentes and Milind Dattawadkar Open System Services (OSS) Update and OSS Developer's Tips Marc Fuentes and Milind Dattawadkar 2010 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without

More information

Appendix A: FreeBSD. Operating System Concepts 9 th Edition

Appendix A: FreeBSD. Operating System Concepts 9 th Edition Appendix A: FreeBSD Operating System Concepts 9 th Edition Silberschatz, Galvin and Gagne 2013 Module A: The FreeBSD System UNIX History Design Principles Programmer Interface User Interface Process Management

More information

ECE 598 Advanced Operating Systems Lecture 23

ECE 598 Advanced Operating Systems Lecture 23 ECE 598 Advanced Operating Systems Lecture 23 Vince Weaver http://web.eece.maine.edu/~vweaver vincent.weaver@maine.edu 21 April 2016 Don t forget HW#9 Midterm next Thursday Announcements 1 Process States

More information

Architectural Support for Operating Systems. Jinkyu Jeong ( Computer Systems Laboratory Sungkyunkwan University

Architectural Support for Operating Systems. Jinkyu Jeong ( Computer Systems Laboratory Sungkyunkwan University Architectural Support for Operating Systems Jinkyu Jeong ( jinkyu@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Today s Topics Basic services of OS Basic computer system

More information

CptS 360 (System Programming) Unit 6: Files and Directories

CptS 360 (System Programming) Unit 6: Files and Directories CptS 360 (System Programming) Bob Lewis School of Engineering and Applied Sciences Washington State University Spring, 2019 Motivation Need to know your way around a filesystem. A properly organized filesystem

More information

Roadmap. Tevfik Ko!ar. CSC Operating Systems Fall Lecture - III Processes. Louisiana State University. Processes. September 1 st, 2009

Roadmap. Tevfik Ko!ar. CSC Operating Systems Fall Lecture - III Processes. Louisiana State University. Processes. September 1 st, 2009 CSC 4103 - Operating Systems Fall 2009 Lecture - III Processes Tevfik Ko!ar Louisiana State University September 1 st, 2009 1 Roadmap Processes Basic Concepts Process Creation Process Termination Context

More information

Preface to the First Edition Preface to the Second Edition Acknowledgments UNIX Operating System Environment p. 1 UNIX: Past and Present p.

Preface to the First Edition Preface to the Second Edition Acknowledgments UNIX Operating System Environment p. 1 UNIX: Past and Present p. Preface to the First Edition p. xv Preface to the Second Edition p. xvii Acknowledgments p. xix UNIX Operating System Environment p. 1 UNIX: Past and Present p. 2 History and Growth of UNIX p. 2 Flavors

More information

Design and Implementation of the MTX Operating System

Design and Implementation of the MTX Operating System Design and Implementation of the MTX Operating System K. C. Wang Design and Implementation of the MTX Operating System 1 3 K. C. Wang School of Electrical Engineering and Computer Science Washington State

More information

CHAPTER 3 - PROCESS CONCEPT

CHAPTER 3 - PROCESS CONCEPT CHAPTER 3 - PROCESS CONCEPT 1 OBJECTIVES Introduce a process a program in execution basis of all computation Describe features of processes: scheduling, creation, termination, communication Explore interprocess

More information

Computer Systems Laboratory Sungkyunkwan University

Computer Systems Laboratory Sungkyunkwan University Concurrent Programming Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Echo Server Revisited int main (int argc, char *argv[]) {... listenfd = socket(af_inet, SOCK_STREAM, 0); bzero((char

More information

CSCE 313 Introduction to Computer Systems. Instructor: Dezhen Song

CSCE 313 Introduction to Computer Systems. Instructor: Dezhen Song CSCE 313 Introduction to Computer Systems Instructor: Dezhen Song Programs, Processes, and Threads Programs and Processes Threads Programs, Processes, and Threads Programs and Processes Threads Processes

More information

CSCE 313: Intro to Computer Systems

CSCE 313: Intro to Computer Systems CSCE 313 Introduction to Computer Systems Instructor: Dr. Guofei Gu http://courses.cse.tamu.edu/guofei/csce313/ Programs, Processes, and Threads Programs and Processes Threads 1 Programs, Processes, and

More information

Chapter 3: Processes. Operating System Concepts 9 th Edition

Chapter 3: Processes. Operating System Concepts 9 th Edition Chapter 3: Processes Silberschatz, Galvin and Gagne 2013 Chapter 3: Processes Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication

More information

Operating system security models

Operating system security models Operating system security models Unix security model Windows security model MEELIS ROOS 1 General Unix model Everything is a file under a virtual root diretory Files Directories Sockets Devices... Objects

More information

Process. Program Vs. process. During execution, the process may be in one of the following states

Process. Program Vs. process. During execution, the process may be in one of the following states What is a process? What is process scheduling? What are the common operations on processes? How to conduct process-level communication? How to conduct client-server communication? Process is a program

More information

Operating System Structure

Operating System Structure Operating System Structure CSCI 4061 Introduction to Operating Systems Applications Instructor: Abhishek Chandra Operating System Hardware 2 Questions Operating System Structure How does the OS manage

More information

Processes. Process Management Chapter 3. When does a process gets created? When does a process gets terminated?

Processes. Process Management Chapter 3. When does a process gets created? When does a process gets terminated? Processes Process Management Chapter 3 1 A process is a program in a state of execution (created but not terminated) Program is a passive entity one on your disk (survivor.class, kelly.out, ) Process is

More information

OS lpr. www. nfsd gcc emacs ls 1/27/09. Process Management. CS 537 Lecture 3: Processes. Example OS in operation. Why Processes? Simplicity + Speed

OS lpr. www. nfsd gcc emacs ls 1/27/09. Process Management. CS 537 Lecture 3: Processes. Example OS in operation. Why Processes? Simplicity + Speed Process Management CS 537 Lecture 3: Processes Michael Swift This lecture begins a series of topics on processes, threads, and synchronization Today: processes and process management what are the OS units

More information

PROCESS MANAGEMENT Operating Systems Design Euiseong Seo

PROCESS MANAGEMENT Operating Systems Design Euiseong Seo PROCESS MANAGEMENT 2016 Operating Systems Design Euiseong Seo (euiseong@skku.edu) Definition A process is a program in execution Context Resources Specifically, Register file state Address space File and

More information

SMD149 - Operating Systems

SMD149 - Operating Systems SMD149 - Operating Systems Roland Parviainen November 3, 2005 1 / 45 Outline Overview 2 / 45 Process (tasks) are necessary for concurrency Instance of a program in execution Next invocation of the program

More information

Using persistent memory to

Using persistent memory to Using persistent memory to Talk build Title a high-performant, Here fully Author Name, Company user space filesystem Krzysztof Czuryło, Intel What it is? pmemfile Low-overhead userspace implementation

More information

What is an Operating System? A Whirlwind Tour of Operating Systems. How did OS evolve? How did OS evolve?

What is an Operating System? A Whirlwind Tour of Operating Systems. How did OS evolve? How did OS evolve? What is an Operating System? A Whirlwind Tour of Operating Systems Trusted software interposed between the hardware and application/utilities to improve efficiency and usability Most computing systems

More information