[lkml]   [2000]   [Dec]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: [RFC] Semaphores used for daemon wakeup
    On Fri, 22 Dec 2000, Daniel Phillips wrote:

    > But isn't this actually a simple situation? How about:

    I had only adapted that example because it had already been posted showing
    one way to do it, and so provided something to compare the sv approach to.

    > dmabuf_alloc(...)
    > {
    > while (1) {
    > spin_lock(&dmabuf_lock);
    > attempt to grab a free buffer;
    > spin_unlock(&dmabuf_lock);
    > if (success)
    > return;
    > down(&dmabuf_wait);
    > }
    > }

    > dmabuf_free(...)
    > {
    > spin_lock(&dmabuf_lock);
    > free up buffer;
    > spin_unlock(&dmabuf_lock);
    > up(&dmabuf_wait);
    > }

    This does things a little differently than the way the original did it.
    I thought the original implied that dmabuf_free() might free up multiple
    buffers. There's no indication in the comments that this is the case, but
    the original, by using vall_sema(), wakes up all dmabuf_alloc()'s that had
    gone to sleep.

    The example wasn't meant to be an ideal use of sv's, but merely as an
    example of how they could be used to achieve the same behavior as the code
    that was posted.

    Paul Cassella

    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to
    Please read the FAQ at

     \ /
      Last update: 2005-03-22 12:52    [W:0.025 / U:1.888 seconds]
    ©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site