Advanced Operating Systems CE5301
10 Questions
0 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

What is a File Descriptor in the context of operating systems?

a struct with all the info about the files

What is a Device Driver responsible for?

  • Interacting directly with the device hardware
  • Registers/Unregisters itself with the kernel
  • Handler functions for file operations
  • All of the above (correct)
  • Can files be viewed as communication channels in operating systems?

    True

    What is the analog of 'open' in the context of connected queues over the Internet?

    <p>Socket</p> Signup and view all the answers

    Which operating system first introduced the concept of a Socket?

    <p>4.2 BSD UNIX</p> Signup and view all the answers

    Low-level I/O in operating systems is directly supported at the system call level.

    <p>True</p> Signup and view all the answers

    What is the return value from the 'fork' system call?

    <p>integer</p> Signup and view all the answers

    Which of the following statements is correct regarding the return value from 'fork'?

    <p>When = 0: Running in new Child process</p> Signup and view all the answers

    The 'wait()' system call waits for the next child to exit and returns the PID of the terminating child. The argument passed is a pointer to an integer variable to hold the ________.

    <p>exit status</p> Signup and view all the answers

    What does the 'execl' function do in the context of the code snippet provided?

    <p>start new program</p> Signup and view all the answers

    Study Notes

    Operating System Fundamentals

    • The Unix Operating System Structure consists of:
      • Applications (User Mode)
      • Standard Libraries (User Mode)
      • Kernel Mode (Hardware Abstraction)
      • Hardware (Device Drivers, Platform Support)

    Process Management

    • The fork() system call:
      • Returns an integer value
      • Value > 0: return value is the PID of the new child process (running in parent process)
      • Value = 0: running in new child process
      • Value < 0: error
    • The wait() system call:
      • Waits for the next child to exit
      • Return value is the PID of the terminating child
      • Argument is a pointer to an integer variable to hold the exit status
    • The exec() family of calls:
      • Replaces the process with a new executable

    I/O Design Concepts

    • Uniformity:
      • File operations, device I/O, and interprocess communication through open, read/write, close
      • Allows simple composition of programs
    • Open before use:
      • Provides opportunity for access control and arbitration
      • Sets up the underlying machinery (data structures)
    • Byte-oriented:
      • Even if blocks are transferred, addressing is in bytes
    • Kernel buffered reads:
      • Streaming and block devices look the same
      • Read blocks process, yielding processor to other tasks
    • Kernel buffered writes:
      • Completion of outgoing transfer decoupled from the application, allowing it to continue

    File System Abstraction

    • High-level idea:
      • Files live in a hierarchical namespace of filenames
    • File:
      • Named collection of data in a file system
      • File data: text, binary, linearized objects
      • File metadata: information about the file (size, modification time, owner, security info)
    • Directory:
      • "Folder" containing files and directories
      • Hierarchical (graphical) naming
      • Path through the directory graph uniquely identifies a file or directory

    C High-Level File API

    • Operates on "streams" - a sequence of bytes, whether text or data, with a position
    • FILE *fopen(const char *filename, const char *mode)
    • int fclose(FILE *fp)

    C Low-Level File API

    • Operations on file descriptors - an OS object representing the state of a file
    • int open(const char *filename, int flags [, mode_t mode])
    • int creat(const char *filename, mode_t mode)
    • int close(int filedes)

    File System Implementation

    • Internal OS file descriptor:
      • A struct with all the information about the file
      • Where it resides
      • Its status
      • How to access it
    • File system driver:
      • vfs_read() function:
        • Checks if the file has a read method
        • Calls the read method if available
        • Otherwise, calls do_sync_read()### File System: from syscall to driver
    • vfs_read function in fs/read_write.c is responsible for handling read system calls
      • Checks if the file is open for reading and if the read operation is valid
      • Verifies the area of memory where the data will be written
      • Calls the read function of the file operations structure
      • Updates the number of bytes read and notifies the file system of the access

    Lower Level Driver

    • Associated with a particular hardware device
    • Registers/unregisters itself with the kernel
    • Handler functions for each of the file operations

    Device Drivers

    • Device-specific code in the kernel that interacts directly with the device hardware
    • Supports a standard, internal interface
    • Same kernel I/O system can interact easily with different device drivers
    • Typically divided into two pieces: top half and bottom half
      • Top half: accessed in call path from system calls, implements standard interface
      • Bottom half: runs as interrupt routine

    Life Cycle of an I/O Request

    • User program initiates I/O request
    • Kernel I/O subsystem handles the request
    • Device driver is called to perform the I/O operation
    • Device driver interacts with the hardware
    • Data is transferred between the device and the kernel
    • Kernel notifies the user program of the I/O completion

    Communication between processes

    • Files can be viewed as communication channels
    • Producer and consumer of a file may be distinct processes
    • May be separated in time
    • Data written once and consumed once can be implemented using a queue

    Request Response Protocol

    • Client issues requests to a server
    • Server performs operations and responds to the client
    • Requests and responses are sent over a communication channel

    Client-Server Models

    • Multiple clients accessing a common server
    • File servers, web, FTP, databases, etc.

    Sockets

    • An abstraction of a network I/O queue
    • Mechanism for inter-process communication
    • Embodies one side of a communication channel
    • Same interface regardless of location of other end
    • Can be local (UNIX socket) or remote (network socket)

    Silly Echo Server and Client

    • Client and server communicate using sockets
    • Client sends request, server responds
    • Data is transferred over the network

    Server Protocol

    • Server creates a socket and binds it to an address
    • Server listens for connections
    • Client connects to server
    • Server accepts connection and forks off a new process to handle it
    • Child process closes listen socket and parent process waits for child to finish
    • Server closes connection socket and exits

    Server Protocol with Protection and Parallelism

    • Server creates a socket and binds it to an address
    • Server listens for connections
    • Client connects to server
    • Server accepts connection and forks off a new process to handle it
    • Child process closes listen socket and parent process waits for child to finish
    • Server closes connection socket and exits
    • Multiple clients can connect to the server concurrently

    Studying That Suits You

    Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

    Quiz Team

    Description

    Lecture on Introduction to I/O, Sockets, and Networking, covering fork, wait, and exec functions in process management.

    More Like This

    Use Quizgecko on...
    Browser
    Browser