lkml.org 
[lkml]   [2000]   [Sep]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: thread rant
    At 22:48 01/09/00, Michael Bacarella wrote:

    >Q: Why do we need threads?
    >A: Because on some operating systems, task switches are expensive.
    >
    >Q: So, threads are a hack to get around operating systems that suck?
    >A: Basically.

    urgh, i think you've missed the point.

    while threads /may/ be abused by many applications where fork() or
    decent-event-queue/state-machine would probably produce much better
    performance (i believe some of the java libraries are a perfect example of
    this), there are _MANY_ applications where threads work, work well, and are
    superior to the alternatives available (fork with shm segments).

    one such example is cpu compultationally-expensive work where some degree
    of working-set is required to be shared between processes. one could use
    fork(), run multiple instances, have them register to a shm segment and
    then implement some form of IPC between them.
    alternatively, you could create 'n' work threads where "n == NR_CPUs" with
    the working-set automatically available to all worker threads. for
    whatever synchronization is required, you don't have to write your IPC
    mechanism - mutexes come standard with things like pthreads. (of course,
    there is no excuse for bad programming or bad algorithms; mutex use should
    be kept to a minimum). perhaps you then need this application to then do
    bulk disk-i/o? one-thread-per-disk-spindle works nicely in this scenario too.

    threads are useful and powerful. perhaps the real problem with threads are
    that it is too easy to write bad code using them.
    caveat emptor.


    cheers,

    lincoln.


    --
    Lincoln Dale Content Services Business Unit
    ltd@cisco.com cisco Systems, Inc. | |
    || ||
    +1 (408) 525-1274 bldg G, 170 West Tasman |||| ||||
    +61 (3) 9659-4294 << San Jose CA 95134 ..:||||||:..:||||||:..

    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2005-03-22 12:38    [W:0.023 / U:0.640 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site