// A simple producer-consumer skeleton using pthreads.
//
// Operating Systems, Spring 2012
#include <cstdlib>
#include <pthread.h>
#include <vector>
template <class T>
class synchronous_queue {
// blah blah blah
}
class Widget {
// blah blah blah
}
static void * c(void * a) {
synchronous_queue<Widget> * q = static_cast<synchronous_queue<Widget>*>(a)
return 0
}
static void * p(void * a) {
synchronous_queue<Widget> * q = static_cast<synchronous_queue<Widget>*>(a)
return 0
}
int main() {
pthread_t cpid, ppid
int s
synchronous_queue<Widget> q
s = pthread_create(&cpid, NULL, c, &q)
if (s ≠ 0) {
// whaa, whaa, whaa
}
s = pthread_create(&ppid, NULL, p, &q)
if (s ≠ 0) {
// whaa, whaa, whaa
}
s = pthread_join(ppid, NULL)
if (s ≠ 0) {
// whaa, whaa, whaa
}
s = pthread_join(cpid, NULL)
if (s ≠ 0) {
// whaa, whaa, whaa
}
exit(EXIT_SUCCESS)
}
// $Log:$
syntax highlighted by Code2HTML, v. 0.9.1