Private barriers

The required implementation of barriers allows any process to join, as long as it knows the barrier_id. With a private barrier, the goal would be to restrict the joining processes to only the process who created the barrier and its descendants. You would need to change the prototype for barrier_create to something like:

int barrier_create(int num_processes, long timeout, int restricted)

Depending on the value of 'restricted' you would then have to check in barrier_join whether the joining process is a descendant of the process that created the barrier. You can find the pid of a process's parent (and other useful information) in its task_struct. Note you will also have a new errno possible in calls to barrier_join, EPERM, if the calling process is trying to join a barrier it doesn't have permission to.

Additional system calls

Debugging kernel functions can be difficult, since there is no way to easily run a debugger, and there's no stdout to write to (you can only write to /var/log/messages with printk). To help debugging, you can add additional system calls, such as one to read information about a barrier (e.g. what the current process count is, what the threshold is, the pid of the creating process, the pids of the waiting processes, etc.) You may want to create a new struct such as "struct barrier_stat", which contains various fields from the barrier_t struct (which fields are useful to a user-level program?), and write a new system call where the kernel will fill in the structure for you:

int barrier_stat(int barrier_num, barrier_stat_t *barrier_info)

returns 0 if the data in the barrier_info struct was successfully collected from the barrier_t struct for barrier_num, or -1 on error.
sets errno to ENOENT if no barrier named barrier_num exists.

See "$man stat" to see a similar type of system call for getting information about a file. You'll also need to read up about how to pass reference variables to and from the kernel.

updated 5/10/05