lkml.org 
[lkml]   [2000]   [Mar]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
Subjectpthreads



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/

\
 
 \ /
  Last update: 2005-03-22 13:57    [W:0.046 / U:0.760 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site