#include #include void *fi(); void *fo(); pthread_t thrdid[2]; char fifo[100000][256]; int fifo_position = 0; char val[256]; int fi_mark = 0; int fo_mark = 0; void put_fifo(char *val) { while (fo_mark != 0); fi_mark = 1; sprintf(fifo[fifo_position], "%s", val); fifo_position++; fi_mark = 0; } char *get_fifo() { while (fi_mark != 0); fo_mark = 1; sprintf(val, "%s", fifo[fifo_position]); if (fifo_position>0) fifo_position--; fo_mark = 0; return (char *)fifo[fifo_position]; } int main() { pthread_create( &thrdid[0], NULL, fi, NULL); pthread_create( &thrdid[1], NULL, fo, NULL); for(;;); return 0; } void *fi() { for (;;) { put_fifo("test"); } } void *fo() { for (;;) { printf("%s\n", get_fifo()); } }