boundedbuffer
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| boundedbuffer [2007/09/24 22:31] – jyang | boundedbuffer [2007/09/25 05:20] (current) – nshafiei | ||
|---|---|---|---|
| Line 273: | Line 273: | ||
| </ | </ | ||
| + | |||
| + | |||
| + | <code c> | ||
| + | |||
| + | // i1 and i2 are initialized to 0 | ||
| + | void put(int data) | ||
| + | { | ||
| + | int i1, i2; | ||
| + | read(" | ||
| + | in(" | ||
| + | if(i1==size)i1=0; | ||
| + | while(i1+1==i2 || (i1+1==size && i2==0)) | ||
| + | | ||
| + | out(" | ||
| + | out(" | ||
| + | } | ||
| + | |||
| + | |||
| + | int get() | ||
| + | { | ||
| + | int i2, data; | ||
| + | in(" | ||
| + | if(i2==size)i2=0; | ||
| + | in(" | ||
| + | out(" | ||
| + | return data; | ||
| + | } | ||
| + | |||
| + | </ | ||
boundedbuffer.1190673063.txt.gz · Last modified: by jyang
