Docsity

Operating Systems Programming Assignment: Adding Custom System Calls in MINIX, Assignments of Operating Systems

Toggle sidebar
bg1
ECS 150, Operating Systems Fall Quarter 2008
Program 3
Due Date: November 12, 2008 Points: 100
Program
1. (100 points) Modify the MINIX kernel to add a system call get2pid with the following interface:
int get2pid(pid t *mypid, pid t *parentpid)
This system call returns the PID of the current process in the variable at the address contained in mypid, and the
PID of the current process’ parent in the variable at the address contained in parentpid. If either argument is
the NULL pointer, nothing for that particular variable is returned.
The system call returns 0 if both pointers are valid for the calling program or NULL; otherwise it returns −1. Be
sure to check that the addresses lie within user space for the calling process!
Write a program to demonstrate your call works. Validate the results using getpid and getppid.
Hint: To add the system call into the kernel, see how getpid and getppid work.
Extra Credit
1. (80 points) Modify the MINIX kernel to add a system call getchpid with the following interface:
int getchpid(int n, pid t childpid[])
This system call returns the PIDs of up to nchildren of the current process in the array childpid and returns the
number of PIDs entered into the array. If either nis non-positive or childpid is NULL, the system call simply
returns the number of child processes of the current process.
If childpid points to an address outside the process’ user address space, or an error of any kind occurs, the
system call returns −1.
Write a program to demonstrate your call works.
Version of November 10, 2008 at 10:14pm Page 1 of 1

Partial preview of the text

Download Operating Systems Programming Assignment: Adding Custom System Calls in MINIX and more Assignments Operating Systems in PDF only on Docsity!

ECS 150, Operating Systems Fall Quarter 2008

Program 3

Due Date: November 12, 2008 Points: 100

Program

  1. (100 points) Modify the MINIX kernel to add a system call get2pid with the following interface:

int get2pid(pid t *mypid, pid t *parentpid)

This system call returns the PID of the current process in the variable at the address contained in mypid, and the PID of the current process’ parent in the variable at the address contained in parentpid. If either argument is the NULL pointer, nothing for that particular variable is returned. The system call returns 0 if both pointers are valid for the calling program or NULL ; otherwise it returns −1. Be sure to check that the addresses lie within user space for the calling process! Write a program to demonstrate your call works. Validate the results using getpid and getppid. Hint: To add the system call into the kernel, see how getpid and getppid work.

Extra Credit

  1. (80 points) Modify the MINIX kernel to add a system call getchpid with the following interface:

int getchpid(int n, pid t childpid[])

This system call returns the PIDs of up to n children of the current process in the array childpid and returns the number of PIDs entered into the array. If either n is non-positive or childpid is NULL , the system call simply returns the number of child processes of the current process. If childpid points to an address outside the process’ user address space, or an error of any kind occurs, the system call returns −1. Write a program to demonstrate your call works.

Version of November 10, 2008 at 10:14pm Page 1 of 1