Fall 2010 - Final Exercises 4304

Fall 2010 - Final Exercises 4304 - CSC 4304 Systems...

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

View Full Document Right Arrow Icon
Page 1/6 CSC 4304 – Systems Programming Fall 2010 – Final Review Exercises Exercise 1: Are the following statements True or False: a. A thread cannot see the variables on another thread's stack. False -- they can since they share memory b. In a non-preemptive thread system, you do not have to worry about race conditions. False -- as threads block and unblock, they may do so in unspecified orders, so you can still have race race conditions. c. A thread may only call pthread_join() on threads which it has created with pthread_create() False -- Any thread can join with any other d. With mutexes, you may have a thread execute instructions atomically with respect to other threads that lock the mutex. True -- That's most often how mutexes are used. e. pthread_mutex_lock() never returns False -- It may block, but it when it unblocks, it will return. f. pthread_exit() returns if there is no error False -- never returns. Exercise 2: Let a process A invoke system(“date | more”), where date and more are two programs. a) Is process A the parent process of the process running date? No! Process A is the parent process a shell process, and the shell process is the parent process of the process running date. b) Is the process running date the parent process of the process running more? You must provide explanation! No! They are sibling processes. In fact, the shell process is the parent process of both of the processes.
Background image of page 1

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

View Full DocumentRight Arrow Icon
Page 2/6 Exercise 3: Answer the following questions about the program telnet: a) What does it do? Telnet accepts two command line arguments: a host name and a port number. It calls request connection on that host-port combination. Once the connection is made, telnet performs two things: it reads in lines from standard input and writes them to the socket; and it reads in lines from the socket and prints them on standard output. Telnet exits when the socket closes or when the user quits. b) We can call telnet a “generic client program.” Why? Telnet is a generic client program because most Unix and other systems have it built in and thus one can write a server program that anyone on the internet can use without having to port a special client program. Structuring servers to work with telnet clients is simple: you serve a socket and then wait for connections. Once you recieve a connection, you receive lines of input along the socket
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 6

Fall 2010 - Final Exercises 4304 - CSC 4304 Systems...

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