Question

Which system call should you use to create get the child process’ exit status? What do...

  1. Which system call should you use to create get the child process’ exit status?
  1. What do operating systems use to allow multiple processes load from and store to the same address without interfering with each other?

Homework Answers

Answer #1

System Call :

A system call is the programmatic way in which a computer program requests a service from the kernel of the operating system it is executed on. A system call is a way for programs to interact with the operating system. A computer program makes a system call when it makes a request to the operating system’s kernel. System call provides the services of the operating system to the user programs via Application Program Interface(API). It provides an interface between a process and operating system to allow user-level processes to request services of the operating system. System calls are the only entry points into the kernel system. All programs needing resources must use system calls.

Services Provided by System Calls :

1. Process creation and management

2. Main memory management

3. File Access, Directory and File system management

4. Device handling(I/O)

5. Protection

6. Networking, etc.

Types of System Calls : There are 5 different categories of system calls –

1. Process control: end, abort, create, terminate, allocate and free memory.

2. File management: create, open, close, delete, read file etc.

3. Device management

4. Information maintenance

5. Communication

System call use to create get the child process exit status :

It is known that fork() system call is used to create a new process which becomes child of the caller process.
Upon exit, the child leaves an exit status that should be returned to the parent. So, when the child finishes it becomes a zombie.

Whenever the child exits or stops, the parent is sent a SIGCHLD signal.
The parent can use the system call wait() or waitpid() along with the macros WIFEXITED and WEXITSTATUS with it to learn about the status of its stopped child.

// C code to find the exit status of child process

#include <stdio.h>

#include <stdlib.h>

#include <unistd.h>

#include <sys/types.h>

#include <sys/wait.h>

  

// Driver code

int main(void)

{

    pid_t pid = fork();

      

    if ( pid == 0 )

    {

       /* The pathname of the file passed to execl()

          is not defined   */

       execl("/bin/sh", "bin/sh", "-c", "./nopath", "NULL");

    }

  

    int status;

      

    waitpid(pid, &status, 0);

  

    if ( WIFEXITED(status) )

    {

        int exit_status = WEXITSTATUS(status);        

        printf("Exit status of the child was %d\n",

                                     exit_status);

    }

    return 0;

}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
The following program calls the fork() system call to create a child process. Suppose that the...
The following program calls the fork() system call to create a child process. Suppose that the actual pids of the parent process and child process are as follows: Parent process: 801 Child process:   802 (as returned by fork) Assume all supporting libraries have been included. => Use the answer text field to write the values of the pids printed at lines 1, 2, 3, and 4 (indicate each line number and the value printed). int main() {      pid_t pid,...
Program Assignment 1: Process Management Objective: This program assignment is given to the Operating Systems course...
Program Assignment 1: Process Management Objective: This program assignment is given to the Operating Systems course to allow the students to figure out how a single process (parent process) creates a child process and how they work on Unix/Linux(/Mac OS X/Windows) environment. Additionally, student should combine the code for describing inter-process communication into this assignment. Both parent and child processes interact with each other through shared memory-based communication scheme or message passing scheme. Environment: Unix/Linux environment (VM Linux or Triton...
C++ project The project will allow you to create a system for tracking the games and...
C++ project The project will allow you to create a system for tracking the games and the scores in terms of graphics, story and replay value and will compute the highest score in each category and the highest overall score. The system will allow you to track 5 games in the following arrays: 1) A string array for the game titles 2) An int array for graphics scores from 1 to 5 3) An int array for replay value from...
You have to create a Library Borrowing System based on the following requirements: When new books...
You have to create a Library Borrowing System based on the following requirements: When new books arrive, these books must be cataloged into the system by a librarian (i.e., entered in the system). Information on a book should include book ID, title, author ID, ISBN, and edition. The system should capture author names so that users can search for an author. The library may carry multiple books by the same author, and an author can have multiple books in the...
Linux commands in terminal What processes are running? In the previous task ("Command Based") you were...
Linux commands in terminal What processes are running? In the previous task ("Command Based") you were already familiar with the command "ps" which shows some or all of the processes that are running. When you run "ps", you start a new process and you can see the actual process in the output. Later in this task you will use "ps" more. The "top" command also shows an overview of the processes that exist on the system but it the overview...
What characteristics of the market of systems do you think created monopoly market that Microsoft’s operating system enjoyed?
Read the following case study carefully and answer the questions given at the END.Playing Monopoly: MicrosoftThe success of Bill Gates together with his company Microsoft and the most favors Windows computer operating systems that are still dominating the PC operating system market has always been an excellent example stimulating the youths in the It industry to follow. But the business success and seemingly amazing technology innovation should not be very strong reasons why the ethical issues related to Microsoft and...
I did already posted this question before, I did get the answer but i am not...
I did already posted this question before, I did get the answer but i am not satisfied with the answer i did the code as a solution not the description as my solution, so i am reposting this question again. Please send me the code as my solution not the description In this project, build a simple Unix shell. The shell is the heart of the command-line interface, and thus is central to the Unix/C programming environment. Mastering use of...
The goal of this assignment is to implement a simple client-server system. You have to use...
The goal of this assignment is to implement a simple client-server system. You have to use Python. The basic functionality of the system is a remote calculator. You first will be sending expressions through the client to the server. The server will then calculate the result of the expression and send it back to the client where it is displayed. The server should also send back to the client the string "Socket Programming" as many times as the absolute value...
For this assignment, you will create a BPMN diagram to depict the business process to get...
For this assignment, you will create a BPMN diagram to depict the business process to get a home mortgage based on the following narrative. You can use either DrawIO or BizAgi to create the process drawing. For this process, you can assume that the loan is a refinance not a home purchase. There are some small differences in the process to refinance an existing mortgage than to get a new mortgage. In the following narrative, I'm explaining all of the...
Which architectural pattern is most appropriate for the following multi-user, web-based system for providing a film...
Which architectural pattern is most appropriate for the following multi-user, web-based system for providing a film and photograph library?(1 Point) Please read textbook Chapter 6.3 Architectural Patterns MVC Pattern which separates presentation and interaction from the system data Layered architecture which organizes the system into layers, with related functionality associated with each layer Repository architecture - all data in a system is managed in a central repository that is accessible to all system components. Components do not interact directly, only...