CS360 Final -- December 11, 1999. 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);


Setjmp()/Longjmp()

#include < setjmp.h >

int setjmp(jmp_buf env);
void longjmp(jmp_buf env, int val);

Dllist stuff

#include "jval.h"

typedef struct dllist {
  struct dllist *flink;
  struct dllist *blink;
  Jval val;
} *Dllist;

extern Dllist new_dllist();
extern free_dllist(Dllist);

extern dll_append(Dllist, Jval);
extern dll_prepend(Dllist, Jval);
extern dll_delete_node(Dllist);
extern int dll_empty(Dllist);

#define dll_traverse(ptr, list) \
  for (ptr = (list)->flink; ptr != (list); ptr = ptr->flink)

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_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);