This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
#define die(msg) do { perror(msg); exit(1); } while(0)
struct pack{ Stack stck; pthread_mutex_t mutex; };
int main(int argc, char *argv[]){ void *trashbin; pthread_t peer[2]; struct pack pck; //initialize pck mutex if( pthread_mutex_init(&( pck.mutex), NULL) != 0 ) die("pthread_mutex_init");
//and make it multi-threaded
if( pthread_create(&peer[0], NULL, doPush, (void*)&pck) != 0 )
die("pthread_create");
//pops an element from stack
//return NULL if there's no element in the stack
void * pop(Stack * stck){
struct stack * de;
void * el;
de = *stck;
*stck = (*stck)->next;
if(de != NULL ){
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |