CS360 Final -- December 12, 2000. Cheat Sheet


Syntax of Relevant System calls

int fork();
int execlp(char *file, char *arg0, ...., char *argn, char * /* NULL */);
int pipe(int filedes[2]);
int wait(int *return_value);
int dup2(int filedes, int diledes2);
int close(int filedes);
char *sbrk(int size);
int lrand48();  /* returns a random integer.  Note, it doesn't call malloc */


Pthreads

#include < pthreads.h >

typedef pthread_t int;

int pthread_create(pthread_t *new_thread_ID,
                   pthread_attr_t *attr,
                   void * (*start_func)(void *), 
                   void *arg);
int pthread_join(pthread_t thread, void **value_ptr);

int pthread_mutex_init(pthread_mutex_t *mp, pthread_mutexattr_t *attr);
int pthread_mutex_lock(pthread_mutex_t *mp);
int pthread_mutex_unlock(pthread_mutex_t *mp);

jthread.h

void jthread_system_init();
int jthread_create(void (*start_func)(void *), void *arg);
void jthread_exit();

socketfun.h

extern int serve_socket(char *hn, int port);
extern int accept_connection(int s);
extern int request_connection(char *hn, int port);