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.