lkml.org 
[lkml]   [2001]   [Jun]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: Alan Cox quote? (was: Re: accounting for threads)


    On Tue, 19 Jun 2001, Alan Cox wrote:

    > There I disagree. Threads introduce parallelism that the majority of user
    > space programmers have trouble getting right (not that C is helpful here).

    s/user space//

    > A threaded program has a set of extremely complex hard to repeat timing based
    > behaviour dependancies. An unthreaded app almost always does the same thing on
    > the same input. From a verification and coverage point of view that is
    > incredibly important.

    Exactly. And that's one of the reasons why event-drivel stuff tends to
    be buggy. In that respect AIO is not going to be much better than threads.

    BTW, threads of execution don't have to share memory to give an
    opportunity of screwup. Lovely example:

    pid = fork():
    if (!pid) {
    while(1) {
    long tmp = lseek(fd, 0, SEEK_CUR);
    long len = lseek(fd, 0, SEEK_END);
    lseek(fd, tmp, SEEK_SET);
    if (!foo(len))
    exit(0);
    sleep(1);
    }
    }
    /* write a lot of stuff to fd */

    That, BTW, is pretty close to the GUI braindamage Larry had refered to -
    helper process implemented a progress bar.

    _Extremely_ nasty data corruption - if child loses timeslice between
    the first and third lseeks and parent happens to get that timeslice and
    write next chunk... Happy, happy, joy, joy - child will put the IO pointer
    back to the place where it used to be and the next chunk will merrily
    overwrite the thing. Real fun to debug - the thing happens rarely (normally
    child has rather high priority after voluntary sleep) and corruption has
    a good chance to be confused for an OS bug. Especially if box with OS foo
    had demonstrated that behaviour couple of times and box with OS bar either
    hadn't done that so far, or corruption hadn't been noticed.

    And yes, it's a real-world example - been there, LARTed the idiot who had
    written that crap.

    -
    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: 2005-03-22 12:55    [W:2.204 / U:0.008 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site