Hi everybody,
I want to execute two C programs simultaneously. Is it possible.
If it is possible, please inform me.
Thanks in advance.
Hi everybody,
I want to execute two C programs simultaneously. Is it possible.
If it is possible, please inform me.
Thanks in advance.
No it is not possible unless you have two microprocessors. However, the effect of two programs running simultaneously can be simulated through multiple threads or processes. How you go about either of those depends on your compiler and operating system though.
In Linux/Unix - dead easy
Just type
Both programs running (more or less) at the same time.Code:./prog1 & ./prog2 &
It's all an illusion though unless you really have multiple processors in your machine. The OS just divides up time between all the active processes to give the illusion that many things are happening at once.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.