[Splashy-devel] Dodgy use of pthread_mutex in splashy.

John Hughes john at Calva.COM
Wed Mar 26 16:49:01 UTC 2008


In splashy_functions.c we have a nice keyevent_loop:

	while (1) 
	{
		... 
		pthread_mutex_lock (&key_mut);
		splashy_wait_for_event ();
		while ((key = splashy_get_key_event ()) > 0)
		{
			...
		}
		pthread_mutex_unlock (&key_mut);
		...
	}

In other threads we read stuff from the socket and attempt to
synchronise with the keyevent_loop by using "key_mut".

For example to do a getpass we do:

	splashy_wake_up ();
	pthread_mutex_lock (&key_mut);
	splashy_get_password (...);
	pthread_mutex_unlock (&key_mut);

The problem is that there is (almost) nothing to make the keyevent_loop
give up the cpu between the pthread_mutex_unlock and re-locking the
mutex, so the socket loop gets shut out.

A demo:

	/sbin/splashy & 
	sleep 4
	splashy_update "getpass enter the password"
	splashy_update "quit"

On a 1 cpu machine the "enter the password" prompt is not shown
immediately, often the only way to get it to come up is to hit F2 a few
times.

	




More information about the Splashy-devel mailing list