parallel programming

Discussion in 'C Programming' started by paytam@gmail.com, Nov 19, 2005.

  1. Guest

    Hi all,
    Is it possible to write parallel programming in C?
    I mean for example a simple program like I have a clock on a program
    that show me current time and and at the same time another job like
    input data from a user.If it is possible PLZ write a simple code for me
    ..
    , Nov 19, 2005
    #1
    1. Advertising

  2. Jack Klein Guest

    On 18 Nov 2005 23:21:38 -0800, wrote in comp.lang.c:

    > Hi all,
    > Is it possible to write parallel programming in C?


    Not in standard C, no. The language defines an abstract computing
    machine that does exactly one thing at a time.

    > I mean for example a simple program like I have a clock on a program
    > that show me current time and and at the same time another job like
    > input data from a user.If it is possible PLZ write a simple code for me


    There are extensions to C, and other languages, that provide ways of
    doing this, if the underlying platform provides support. But they are
    not part of the C language and outside the scope of this group. You
    need to ask in a group that discusses programming for your particular
    compiler and operating system combination to learn about what
    extensions it might offer.

    --
    Jack Klein
    Home: http://JK-Technology.Com
    FAQs for
    comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
    comp.lang.c++ http://www.parashift.com/c -faq-lite/
    alt.comp.lang.learn.c-c++
    http://www.contrib.andrew.cmu.edu/~ajo/docs/FAQ-acllc.html
    Jack Klein, Nov 19, 2005
    #2
    1. Advertising

  3. Malcolm Guest

    <> wrote
    >
    > Is it possible to write parallel programming in C?
    > I mean for example a simple program like I have a clock on a program
    > that show me current time and and at the same time another job like
    > input data from a user.If it is possible PLZ write a simple code for me
    > .

    There are lots of solutions to the problem of writing parallel C code. For
    example there is a language called "parallel C" with instruction like "pfor"
    ( a for loop which can be executed in parallel).
    The one that seems to have caught on is the message passing interface, or
    MPI. Superficially it looks like a familiar series of C function calls. In
    fact you need a special compiler - it cannot be implemented as a normal
    library.

    All of them are currently off-topic. (There might be an argument for
    expanding the scope of the ng to include parallel implementations, but
    presently the convention is that we confine ourselves to ANSI C)
    However you don't need true parallel programing to achieve parallel
    execution.
    For instance as long as you can call a routine called update_clock() more
    frequently than once a second, the clock will appear to the user to be
    ticking along in parallel.

    ANSI C input functions are blocking, so if the user waits five minutes
    before pressing the newline, getc() will wait for him. However there are
    always extension like "kbhit" available which get round this problem,
    allowing you to check for input and, if it is not present, update the clock.
    Malcolm, Nov 19, 2005
    #3
  4. Tim Prince Guest

    Malcolm wrote:
    > <> wrote
    >
    >>Is it possible to write parallel programming in C?
    >>I mean for example a simple program like I have a clock on a program
    >>that show me current time and and at the same time another job like
    >>input data from a user.If it is possible PLZ write a simple code for me
    >>.

    >
    > There are lots of solutions to the problem of writing parallel C code. For
    > example there is a language called "parallel C" with instruction like "pfor"
    > ( a for loop which can be executed in parallel).
    > The one that seems to have caught on is the message passing interface, or
    > MPI. Superficially it looks like a familiar series of C function calls. In
    > fact you need a special compiler - it cannot be implemented as a normal
    > library.
    >


    That is exactly how it is implemented, even though a wrapper is supplied
    for each supported compiler, and it is possible, though misguided, to
    avoid the wrapper and invoke your C directly.
    You may be thinking of OpenMP, which is impractical to implement without
    at least a special pre-processor. There are also compilers which can
    implement a limited subset of OpenMP simply by throwing a command line
    switch.
    The OP problem looks more like homework aimed at the beginnings of
    teaching about an operating system, not what many of us think of as
    parallel programming. Yes, it is possible to write an OS largely in C,
    e.g. gnu/linux. Still OT, as it hasn't been done in purely standard C.
    Tim Prince, Nov 19, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. karthik
    Replies:
    5
    Views:
    11,005
    Dale King
    Jul 25, 2003
  2. Paul Perrone
    Replies:
    0
    Views:
    14,428
    Paul Perrone
    Aug 21, 2003
  3. Soren
    Replies:
    4
    Views:
    1,259
    c d saunter
    Feb 14, 2008
  4. Vivek Menon
    Replies:
    5
    Views:
    3,351
    Paul Uiterlinden
    Jun 8, 2011
  5. Vivek Menon
    Replies:
    0
    Views:
    1,766
    Vivek Menon
    Jun 10, 2011
Loading...

Share This Page