Messages in this thread | | | From | Kyle Moffett <> | Subject | Re: pthread_mutex_unlock (was Re: sched_yield() makes OpenLDAP slow) | Date | Thu, 26 Jan 2006 09:15:15 -0500 |
| |
Haven't you OpenLDAP guys realized that the pthread model you're actually looking for is this? POSIX mutexes are not designed to mandate scheduling requirements *precisely* because this achieves your scheduling goals by explicitly stating what they are.
s: pthread_mutex_lock(&mutex); s: pthread_cond_wait(&wake_slave, &mutex);
m: [do some work] m: pthread_cond_signal(&wake_slave); m: pthread_cond_wait(&wake_master, &mutex);
s: [return from pthread_cond_wait] s: [do some work] s: pthread_cond_signal(&wake_master); s: pthread_cond_wait(&wake_slave, &mutex);
Of course, if that's the model you're looking for, you could always do this instead:
void master_func() { while (1) { [do some work] slave_func(); } }
void slave_func() { [do some work] }
The semantics are effectively the same.
Cheers, Kyle Moffett
-- Premature optimization is the root of all evil in programming -- C.A.R. Hoare
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |