lkml.org 
[lkml]   [2006]   [Jan]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    From
    SubjectRe: pthread_mutex_unlock (was Re: sched_yield() makes OpenLDAP slow)
    Date
    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/

    \
     
     \ /
      Last update: 2006-01-26 15:17    [W:7.685 / U:0.132 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site