Inter Process Communication Basics
45 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 information does the ps command provide?

  • List of open files of running processes
  • Statistics of virtual memory subsystem
  • System configuration variables
  • Information about all running processes (correct)
  • Which command reports on virtual memory statistics?

  • ps
  • lsof
  • vmstat (correct)
  • getconf
  • What does the getrusage() system call provide information about?

  • System resource usage (correct)
  • Number of running processes
  • System configuration variables
  • Open files of a process
  • Which command would you use to display system configuration variables?

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

    What does a successful call to getrusage() return?

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

    What is the process image primarily used for?

    <p>Preparing the executable file for program execution</p> Signup and view all the answers

    Which segment of the process image is read-only and contains executable instructions?

    <p>Code segment</p> Signup and view all the answers

    How does the stack segment manage memory?

    <p>In a Last-In-First-Out (LIFO) order</p> Signup and view all the answers

    What does the child process return in the provided program found in the main function?

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

    Which type of data segment contains uninitialized static and global variables?

    <p>BSS segment</p> Signup and view all the answers

    In the program, which function is used to wait for the child process to finish executing?

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

    What function calls are typically associated with the heap segment?

    <p>malloc() and calloc()</p> Signup and view all the answers

    What is characteristic of the data segment's size during program execution?

    <p>It can change due to variable modifications.</p> Signup and view all the answers

    What happens if the waitid function encounters an error during execution?

    <p>Returns -1 and sets appropriate error number</p> Signup and view all the answers

    What is the purpose of a process group in Unix-like operating systems?

    <p>To group multiple processes sharing the same PGID</p> Signup and view all the answers

    In which order does the stack segment grow?

    <p>From higher address to lower address</p> Signup and view all the answers

    What command can be executed to determine segment size?

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

    What is the role of the process group leader?

    <p>To create the process group and own the PGID</p> Signup and view all the answers

    Which statement best describes sessions in process management?

    <p>It is a collection of process groups</p> Signup and view all the answers

    What enables a shell user to manage multiple commands simultaneously?

    <p>Job Control</p> Signup and view all the answers

    In the context of the program, what is indicated by the return value of 1 for the main function?

    <p>Error occurred during waitid execution</p> Signup and view all the answers

    What is the purpose of the chmod command in the context of shell scripts?

    <p>To provide execute permissions to the file</p> Signup and view all the answers

    Which command is used to resume a stopped job in the foreground?

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

    What is a process ID (PID)?

    <p>A unique positive integer identifying a process</p> Signup and view all the answers

    What command would you use to list jobs currently managed by the shell?

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

    What is the purpose of the getpid() system call?

    <p>To return the process ID of the calling process</p> Signup and view all the answers

    Which command displays the ongoing CPU and memory resource usage in real-time?

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

    What is the maximum limit for process IDs in the system?

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

    Which system call is used to get the parent process ID?

    <p>getppid()</p> Signup and view all the answers

    To stop a currently running process in the shell, which key combination should you use?

    <p>CTRL+Z</p> Signup and view all the answers

    What function does the system() library function serve in the provided program?

    <p>To execute a shell command</p> Signup and view all the answers

    What happens when you use the kill command with a specific job number?

    <p>It terminates the specified job</p> Signup and view all the answers

    In shell scripting, what does the sleep command do?

    <p>It pauses execution for a specified duration</p> Signup and view all the answers

    What will the command 'ps -ef' provide when called in the program?

    <p>Details of the current active processes</p> Signup and view all the answers

    What does the output 'My process ID is %d' signify in the program?

    <p>The unique identifier of the calling process outputted as an integer</p> Signup and view all the answers

    What will happen if you attempt to run a job in the background using the command bg %2?

    <p>It starts the second stopped job in the background</p> Signup and view all the answers

    Which of the following best describes the return value of the getppid() call?

    <p>It always returns a unique identifier of the parent process</p> Signup and view all the answers

    What is the output produced by the command getppid() in the child process?

    <p>PPID is 166629</p> Signup and view all the answers

    What happens when the fork() function returns a negative value?

    <p>An error occurs indicating fork() failure.</p> Signup and view all the answers

    Which of the following correctly describes the difference between exit() and _exit()?

    <p>exit() performs cleanup before control returns to the kernel, while _exit() does not.</p> Signup and view all the answers

    What function is used to register a cleanup function that is called upon normal termination of a program?

    <p>atexit()</p> Signup and view all the answers

    In the sample program with 'atexit_sample.c', what is printed just before the program exits?

    <p>Hello, World!</p> Signup and view all the answers

    Which option correctly states the output when both the parent and child processes execute after a fork() call?

    <p>The parent process will have a different PID from the child process.</p> Signup and view all the answers

    What is the behavior of the program if the function registered by atexit() is not called?

    <p>The program may not clean up resources properly.</p> Signup and view all the answers

    What will happen if the program with atexit_sample.c registers multiple functions with atexit()?

    <p>Functions will be called in reverse order of registration.</p> Signup and view all the answers

    Study Notes

    Inter Process Communication (IPC)

    • IPC is a mechanism for communication between processes in a single system.
    • Two types of processes can communicate: related processes and unrelated processes.
    • Related processes initiate communication from one to another (e.g., parent and child).
    • Unrelated processes can communicate with each other.

    Pipes

    • Used for communication between related processes.
    • Half-duplex communication is possible; one process communicating to another.
    • To achieve full-duplex communication (both ways), two pipes are required.

    FIFO

    • Used for communication between unrelated processes.
    • Enables full-duplex communication (both ways simultaneously).

    Message Queues

    • Enables communication between two or more processes.
    • Full-duplex communication is possible.
    • Processes communicate through posting and retrieving messages from a queue.
    • Messages are removed from the queue after being retrieved.

    Shared Memory

    • Used for communication between two or more processes via a common memory area.
    • Synchronization mechanisms to protect the shared memory from concurrent access are needed.

    Semaphores

    • Synchronization mechanisms used to coordinate access to shared memory by multiple processes.
    • A semaphore acts as a lock or protection mechanism to prevent multiple processes from accessing the shared memory simultaneously.
    • A process that wants to access shared memory must lock the semaphore.
    • The semaphore is released when the access is no longer needed.

    Signals

    • A mechanism for communication between multiple processes.
    • One process sends a signal, and the destination process handles it.
    • Signals are identified by a number and recognized by the process.

    Process Information

    • A process is a program in execution.
    • A program is a file containing instructions for a process.
    • Each process has a unique positive integer called a process ID (PID).
    • The kernel sets limits on the maximum PID value.
    • The system call getpid() returns the PID of the calling process.
    • The system call getppid() returns the parent process ID (PPID).

    Process Image

    • Contains the executable instructions: code segment or text segment.
    • Data segment: static & global variables, initialized & uninitialized (BSS).
    • Stack segment: Automatic variables & function parameters usage (LIFO).
    • Heap segment: Dynamically allocated variables (growing downward from high addresses).

    Studying That Suits You

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

    Quiz Team

    Related Documents

    Description

    This quiz covers the essential mechanisms of Inter Process Communication (IPC), including pipes, FIFO, message queues, and shared memory. You'll learn about how processes, both related and unrelated, communicate using these different methods. Test your understanding of these concepts and their applications in computer systems.

    More Like This

    Software Process Communication
    18 questions

    Software Process Communication

    MesmerizingLeprechaun avatar
    MesmerizingLeprechaun
    Linux File Communication and Attributes
    23 questions
    Use Quizgecko on...
    Browser
    Browser