mt - METU Department of Computer Engineering CEng 536 -...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: METU Department of Computer Engineering CEng 536 - Advanced Unix Fall 2007-2008 Midterm (Take Home / Due: Dec 3, 14:00/5 questions, 110 points, 5 pages) Name: No: Signature: Note: You are not expected to give complete codes in any of the questions. Just provide significant parts of the code. Replace details with simple verbal description, use pseudo-code whenever appropriate. Your code is not expected to work, just describe primary parts of such a program. Question 1 : (20 pts) Write a function void pipeall(char *commands, int n) that will get n commands in the first parameter array and pipe them in sequence. The first one will take standard input from current stdin and the last one will send standart output to current standard output. All input/output in between is changed as if shell executed: command[0] | command[1] | ... | command[n-1] . Simply exec() commands without arguments without considering environment and path. void pipeall(char *commands, int n) { 1 Question 2 : (20+10 pts) a) In Sys V IPC, we have arrays of semaphors and each semaphor is a counting semaphore. You are asked to implement counting semaphores using pthread mutexes in a multi-threaded program. You will implement the following functions: void up(struct pthread_sem *semstr) int down(struct pthread_sem *semstr, int block) pthread sem structure contains a mutex and the other fields you might require (count value for example).structure contains a mutex and the other fields you might require (count value for example)....
View Full Document

Page1 / 5

mt - METU Department of Computer Engineering CEng 536 -...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online