pthreads

From: Richard B. Johnson (root@chaos.analogic.com)
Date: Fri Mar 17 2000 - 18:38:58 EST


I fixed up some typos....

And compiled it as:

gcc -o xxx xxx.c /usr/lib/libpthread.so

(I don't have threads library set up in LD_LIBRARY_PATH environment)

It compiles (and runs).

include <stdio.h>
include <pthread.h>

pthread_t a_thread;
pthread_attr_t a_thread_attribute;
void thread_function(void*argument);
char *some_argument;

int flag =0;

main()
{

        pthread_create(&a_thread,
        &a_thread_attribute,
        (void*)&thread_function,
        (void*)&some_argument);

        while(flag != 1)
        ;

        printf("Thread1 exiting..");
}

void thread_function(void *argument)
{
  int count =0;
  while(count<10)
        {
        printf("Thread 2 is running %d",count);
        }

flag =1;

printf("Thread 2 is exiting..");
}

Cheers,
Dick Johnson

Penguin : Linux version 2.3.41 on an i686 machine (800.63 BogoMips).

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Thu Mar 23 2000 - 21:00:25 EST