Skip to contentSkip to conversation

using pthread on usermode, almost works.. but new thread blocks execution

Qemu-devel Henri Zikken 1 participant 1 message Apr 22, 2009

lore
Share & tools
lore
#0 lore raw

Though I know it's not recommended, I'm trying to use threads on qemu-ppc usermode. Unfortunatelly I have no other options.

Though I get no errors and the app does run, the created thread hogs the system.

I have tried setting a different scheduler, sigmask, and so on, but to no avail.

I'm using a Debian system, the target platform is powerpc-603. I use crosstools to compile.

This demo program shoud printout 'foo' and 'bar'.. but when run under qemu-ppc (usermode) it only keeps printing 'foo'.

Are there any options to fix this problem, or should I just accept that this isn't going to work?

#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <execinfo.h>
#include <signal.h>

void *start_routine(void *arg)

{	int i;
	while (1==1) {
	   printf("foo\n");
	   i+1;
	   sched_yield();	   
	} 	
}

int main(int argc, char *argv[])

{		
	pthread_t p_thread[1];	
	int cnt;
	int i;
	pthread_attr_t tattr;
    sigset_t *newset, *oldset;
	pthread_attr_init(&tattr);	
    sigfillset( newset );
    pthread_sigmask( SIG_BLOCK, newset, oldset );
	pthread_attr_setschedpolicy( &tattr, SCHED_RR );
	pthread_create( &p_thread[0], &tattr, start_routine, (void *)cnt );	    
	
	
	while (1==1) {
	   printf("bar\n");	   
	   i+1;
	   sched_yield();	   
	}
}

Best regards,

Henri Zikken