Task threading question
Stefan Bruda
yellowdog-general@lists.terrasoftsolutions.com
Fri Feb 6 15:25:02 2004
At 15:43 -0500 on 2004-2-6 Duke Robillard wrote:
>
> threads and processes are both still KSEs created by clone().
Here is proof: the following 11-thread program brings both processors
on my dual G5 to 100% load, as in
CPU states: cpu user nice system irq softirq iowait idle
total 198.6% 0.0% 1.4% 0.0% 0.0% 0.0% 0.0%
cpu00 98.6% 0.0% 1.4% 0.0% 0.0% 0.0% 0.0%
cpu01 100.0% 0.0% 0.0% 0.0% 0.0% 0.0% 0.0%
It is always fun to see a 200% load. :-)
#include <pthread.h>
void* do_nothing (void* ignore) {
while(1);
}
int main (int argc, char** argv) {
pthread_t tt;
pthread_attr_t ta;
pthread_attr_init(&ta);
pthread_attr_setdetachstate(&ta,PTHREAD_CREATE_DETACHED);
int i;
for (i = 0; i < 10; i++) {
if ( pthread_create(&tt, &ta, do_nothing, 0) != 0 ) {
perror("pthread_create");
return 1;
}
}
while(1);
}
--
If it was so, it might be; and if it were so, it would be; but as
it isn't, it ain't. That's logic.
--Lewis Carroll, Through the Looking-Glass