first commit
This commit is contained in:
20
CS4210/Readings/CVS/Entries
Normal file
20
CS4210/Readings/CVS/Entries
Normal file
@@ -0,0 +1,20 @@
|
||||
/ProducerConsumer.c/1.1/Fri Feb 24 00:34:28 2006//
|
||||
/Psyche.pdf/1.1/Fri Feb 24 00:35:15 2006/-kb/
|
||||
/SRC-035.pdf/1.1/Fri Feb 24 00:34:20 2006/-kb/
|
||||
/ThreadsSquare.c/1.1/Fri Feb 24 00:34:25 2006//
|
||||
/anderson-spinlock.pdf/1.1/Fri Feb 24 00:35:19 2006/-kb/
|
||||
/eykholt.ps/1.1/Fri Feb 24 00:34:41 2006//
|
||||
/fedorova_CMT.pdf/1.1/Fri Feb 24 00:34:31 2006/-kb/
|
||||
/ousterhout-threads.ppt/1.1/Fri Feb 24 00:35:32 2006/-kb/
|
||||
/p175-bershad.pdf/1.1/Fri Feb 24 00:35:42 2006/-kb/
|
||||
/p24-bloom.pdf/1.1/Fri Feb 24 00:34:34 2006/-kb/
|
||||
/pai99flash.pdf/1.1/Fri Feb 24 00:35:23 2006/-kb/
|
||||
/pres.pdf/1.1/Fri Feb 24 00:35:27 2006/-kb/
|
||||
/rpc-birrell84.pdf/1.1/Fri Feb 24 00:35:45 2006/-kb/
|
||||
/smli_tr-94-29.pdf/1.1/Fri Feb 24 00:35:49 2006/-kb/
|
||||
/sprite-caching.ps/1.1/Fri Feb 24 01:46:42 2006//
|
||||
/stein92implementing.pdf/1.1/Fri Feb 24 00:35:11 2006/-kb/
|
||||
/threads-hotos-2003.pdf/1.1/Fri Feb 24 00:35:39 2006/-kb/
|
||||
/wollrath.pdf/1.1/Fri Feb 24 00:35:51 2006/-kb/
|
||||
/DSM_protic.pdf/1.1/Tue Apr 25 21:59:37 2006/-kb/
|
||||
D
|
||||
19
CS4210/Readings/CVS/Entries.Extra
Normal file
19
CS4210/Readings/CVS/Entries.Extra
Normal file
@@ -0,0 +1,19 @@
|
||||
/ProducerConsumer.c////*///
|
||||
/Psyche.pdf////*///
|
||||
/SRC-035.pdf////*///
|
||||
/ThreadsSquare.c////*///
|
||||
/anderson-spinlock.pdf////*///
|
||||
/eykholt.ps////*///
|
||||
/fedorova_CMT.pdf////*///
|
||||
/ousterhout-threads.ppt////*///
|
||||
/p175-bershad.pdf////*///
|
||||
/p24-bloom.pdf////*///
|
||||
/pai99flash.pdf////*///
|
||||
/pres.pdf////*///
|
||||
/rpc-birrell84.pdf////*///
|
||||
/smli_tr-94-29.pdf////*///
|
||||
/sprite-caching.ps////*///
|
||||
/stein92implementing.pdf////*///
|
||||
/threads-hotos-2003.pdf////*///
|
||||
/wollrath.pdf////*///
|
||||
/DSM_protic.pdf////*///
|
||||
19
CS4210/Readings/CVS/Entries.Extra.Old
Normal file
19
CS4210/Readings/CVS/Entries.Extra.Old
Normal file
@@ -0,0 +1,19 @@
|
||||
/ProducerConsumer.c////*///
|
||||
/Psyche.pdf////*///
|
||||
/SRC-035.pdf////*///
|
||||
/ThreadsSquare.c////*///
|
||||
/anderson-spinlock.pdf////*///
|
||||
/eykholt.ps////*///
|
||||
/fedorova_CMT.pdf////*///
|
||||
/ousterhout-threads.ppt////*///
|
||||
/p175-bershad.pdf////*///
|
||||
/p24-bloom.pdf////*///
|
||||
/pai99flash.pdf////*///
|
||||
/pres.pdf////*///
|
||||
/rpc-birrell84.pdf////*///
|
||||
/smli_tr-94-29.pdf////*///
|
||||
/sprite-caching.ps////*///
|
||||
/stein92implementing.pdf////*///
|
||||
/threads-hotos-2003.pdf////*///
|
||||
/wollrath.pdf////*///
|
||||
/DSM_protic.pdf////*///
|
||||
20
CS4210/Readings/CVS/Entries.Old
Normal file
20
CS4210/Readings/CVS/Entries.Old
Normal file
@@ -0,0 +1,20 @@
|
||||
/ProducerConsumer.c/1.1/Fri Feb 24 00:34:28 2006//
|
||||
/Psyche.pdf/1.1/Fri Feb 24 00:35:15 2006/-kb/
|
||||
/SRC-035.pdf/1.1/Fri Feb 24 00:34:20 2006/-kb/
|
||||
/ThreadsSquare.c/1.1/Fri Feb 24 00:34:25 2006//
|
||||
/anderson-spinlock.pdf/1.1/Fri Feb 24 00:35:19 2006/-kb/
|
||||
/eykholt.ps/1.1/Fri Feb 24 00:34:41 2006//
|
||||
/fedorova_CMT.pdf/1.1/Fri Feb 24 00:34:31 2006/-kb/
|
||||
/ousterhout-threads.ppt/1.1/Fri Feb 24 00:35:32 2006/-kb/
|
||||
/p175-bershad.pdf/1.1/Fri Feb 24 00:35:42 2006/-kb/
|
||||
/p24-bloom.pdf/1.1/Fri Feb 24 00:34:34 2006/-kb/
|
||||
/pai99flash.pdf/1.1/Fri Feb 24 00:35:23 2006/-kb/
|
||||
/pres.pdf/1.1/Fri Feb 24 00:35:27 2006/-kb/
|
||||
/rpc-birrell84.pdf/1.1/Fri Feb 24 00:35:45 2006/-kb/
|
||||
/smli_tr-94-29.pdf/1.1/Fri Feb 24 00:35:49 2006/-kb/
|
||||
/sprite-caching.ps/1.1/Fri Feb 24 01:46:42 2006//
|
||||
/stein92implementing.pdf/1.1/Fri Feb 24 00:35:11 2006/-kb/
|
||||
/threads-hotos-2003.pdf/1.1/Fri Feb 24 00:35:39 2006/-kb/
|
||||
/wollrath.pdf/1.1/Fri Feb 24 00:35:51 2006/-kb/
|
||||
/DSM_protic.pdf/0/dummy timestamp/-kb/
|
||||
D
|
||||
1
CS4210/Readings/CVS/Repository
Normal file
1
CS4210/Readings/CVS/Repository
Normal file
@@ -0,0 +1 @@
|
||||
CS4210/Readings
|
||||
1
CS4210/Readings/CVS/Root
Normal file
1
CS4210/Readings/CVS/Root
Normal file
@@ -0,0 +1 @@
|
||||
:ext:asskoala@192.168.0.3:/usr/_CVS
|
||||
BIN
CS4210/Readings/DSM_protic.pdf
Normal file
BIN
CS4210/Readings/DSM_protic.pdf
Normal file
Binary file not shown.
80
CS4210/Readings/ProducerConsumer.c
Normal file
80
CS4210/Readings/ProducerConsumer.c
Normal file
@@ -0,0 +1,80 @@
|
||||
#include<pthread.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/* Producer/consumer program illustrating conditional variables */
|
||||
|
||||
/* Size of shared buffer */
|
||||
#define BUF_SIZE 3
|
||||
|
||||
int buffer[BUF_SIZE]; /* shared buffer */
|
||||
int add=0; /* place to add next element */
|
||||
int rem=0; /* place to remove next element */
|
||||
int num=0; /* number elements in buffer */
|
||||
pthread_mutex_t m=PTHREAD_MUTEX_INITIALIZER; /* mutex lock for buffer */
|
||||
pthread_cond_t c_cons=PTHREAD_COND_INITIALIZER; /* consumer waits on this cond var */
|
||||
pthread_cond_t c_prod=PTHREAD_COND_INITIALIZER; /* producer waits on this cond var */
|
||||
|
||||
void *producer(void *param);
|
||||
void *consumer(void *param);
|
||||
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
pthread_t tid1, tid2; /* thread identifiers */
|
||||
int i;
|
||||
|
||||
/* create the threads; may be any number, in general */
|
||||
if (pthread_create(&tid1,NULL,producer,NULL) != 0) {
|
||||
fprintf (stderr, "Unable to create producer thread\n");
|
||||
exit (1);
|
||||
}
|
||||
if (pthread_create(&tid2,NULL,consumer,NULL) != 0) {
|
||||
fprintf (stderr, "Unable to create consumer thread\n");
|
||||
exit (1);
|
||||
}
|
||||
/* wait for created thread to exit */
|
||||
pthread_join(tid1,NULL);
|
||||
pthread_join(tid2,NULL);
|
||||
printf ("Parent quiting\n");
|
||||
}
|
||||
|
||||
|
||||
/* Produce value(s) */
|
||||
void *producer(void *param)
|
||||
{
|
||||
int i;
|
||||
for (i=1; i<=20; i++) {
|
||||
/* Insert into buffer */
|
||||
pthread_mutex_lock (&m);
|
||||
if (num > BUF_SIZE) exit(1); /* overflow */
|
||||
while (num == BUF_SIZE) /* block if buffer is full */
|
||||
pthread_cond_wait (&c_prod, &m);
|
||||
/* if executing here, buffer not full so add element */
|
||||
buffer[add] = i;
|
||||
add = (add+1) % BUF_SIZE;
|
||||
num++;
|
||||
pthread_mutex_unlock (&m);
|
||||
pthread_cond_signal (&c_cons);
|
||||
printf ("producer: inserted %d\n", i); fflush (stdout);
|
||||
}
|
||||
printf ("producer quiting\n"); fflush (stdout);
|
||||
}
|
||||
|
||||
/* Consume value(s); Note the consumer never terminates */
|
||||
void *consumer(void *param)
|
||||
{
|
||||
int i;
|
||||
while (1) {
|
||||
pthread_mutex_lock (&m);
|
||||
if (num < 0) exit(1); /* underflow */
|
||||
while (num == 0) /* block if buffer empty */
|
||||
pthread_cond_wait (&c_cons, &m);
|
||||
/* if executing here, buffer not empty so remove element */
|
||||
i = buffer[rem];
|
||||
rem = (rem+1) % BUF_SIZE;
|
||||
num--;
|
||||
pthread_mutex_unlock (&m);
|
||||
pthread_cond_signal (&c_prod);
|
||||
printf ("Consume value %d\n", i); fflush(stdout);
|
||||
}
|
||||
}
|
||||
|
||||
BIN
CS4210/Readings/Psyche.pdf
Normal file
BIN
CS4210/Readings/Psyche.pdf
Normal file
Binary file not shown.
BIN
CS4210/Readings/SRC-035.pdf
Normal file
BIN
CS4210/Readings/SRC-035.pdf
Normal file
Binary file not shown.
44
CS4210/Readings/ThreadsSquare.c
Normal file
44
CS4210/Readings/ThreadsSquare.c
Normal file
@@ -0,0 +1,44 @@
|
||||
#include<pthread.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/* Example program creating thread to compute square of value */
|
||||
|
||||
int value; /* thread stores result here */
|
||||
void *my_thread(void *param); /* the thread */
|
||||
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
pthread_t tid; /* thread identifier */
|
||||
int retcode;
|
||||
|
||||
/* check input parameters */
|
||||
if (argc != 2) {
|
||||
fprintf (stderr, "usage: a.out <integer value>\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/* create the thread */
|
||||
retcode = pthread_create(&tid,NULL,my_thread,argv[1]);
|
||||
if (retcode != 0) {
|
||||
fprintf (stderr, "Unable to create thread\n");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
/* wait for created thread to exit */
|
||||
pthread_join(tid,NULL);
|
||||
printf ("I am the parent: Square = %d\n", value);
|
||||
}
|
||||
|
||||
|
||||
/* The thread will begin control in this function */
|
||||
void *my_thread(void *param)
|
||||
{
|
||||
int i = atoi (param);
|
||||
|
||||
printf ("I am the child, passed value %d\n", i);
|
||||
value = i * i;
|
||||
|
||||
/* next line is not really necessary */
|
||||
pthread_exit(0);
|
||||
}
|
||||
|
||||
BIN
CS4210/Readings/anderson-spinlock.pdf
Normal file
BIN
CS4210/Readings/anderson-spinlock.pdf
Normal file
Binary file not shown.
7522
CS4210/Readings/eykholt.ps
Normal file
7522
CS4210/Readings/eykholt.ps
Normal file
File diff suppressed because it is too large
Load Diff
BIN
CS4210/Readings/fedorova_CMT.pdf
Normal file
BIN
CS4210/Readings/fedorova_CMT.pdf
Normal file
Binary file not shown.
BIN
CS4210/Readings/ousterhout-threads.ppt
Normal file
BIN
CS4210/Readings/ousterhout-threads.ppt
Normal file
Binary file not shown.
BIN
CS4210/Readings/p175-bershad.pdf
Normal file
BIN
CS4210/Readings/p175-bershad.pdf
Normal file
Binary file not shown.
BIN
CS4210/Readings/p24-bloom.pdf
Normal file
BIN
CS4210/Readings/p24-bloom.pdf
Normal file
Binary file not shown.
BIN
CS4210/Readings/pai99flash.pdf
Normal file
BIN
CS4210/Readings/pai99flash.pdf
Normal file
Binary file not shown.
BIN
CS4210/Readings/pres.pdf
Normal file
BIN
CS4210/Readings/pres.pdf
Normal file
Binary file not shown.
BIN
CS4210/Readings/rpc-birrell84.pdf
Normal file
BIN
CS4210/Readings/rpc-birrell84.pdf
Normal file
Binary file not shown.
BIN
CS4210/Readings/smli_tr-94-29.pdf
Normal file
BIN
CS4210/Readings/smli_tr-94-29.pdf
Normal file
Binary file not shown.
13492
CS4210/Readings/sprite-caching.ps
Normal file
13492
CS4210/Readings/sprite-caching.ps
Normal file
File diff suppressed because it is too large
Load Diff
BIN
CS4210/Readings/stein92implementing.pdf
Normal file
BIN
CS4210/Readings/stein92implementing.pdf
Normal file
Binary file not shown.
BIN
CS4210/Readings/threads-hotos-2003.pdf
Normal file
BIN
CS4210/Readings/threads-hotos-2003.pdf
Normal file
Binary file not shown.
BIN
CS4210/Readings/wollrath.pdf
Normal file
BIN
CS4210/Readings/wollrath.pdf
Normal file
Binary file not shown.
Reference in New Issue
Block a user