By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,503 Members | 1,608 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,503 IT Pros & Developers. It's quick & easy.

parallel programming

P: n/a
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 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On 18 Nov 2005 23:21:38 -0800, pa****@gmail.com 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/~a...FAQ-acllc.html
Nov 19 '05 #2

P: n/a
<pa****@gmail.com> 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.
Nov 19 '05 #3

P: n/a
Malcolm wrote:
<pa****@gmail.com> 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.
Nov 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.