HelloWorld

cohadar

HelloWorld

Let us write a standard hello world program.


program HelloWorld;
begin
writeln('hello world');
end.

It writes the message to the console, big deal, same as in standard pascal. ParaPascal is supposed to simulate parallel execution, let us try something more concurrent.



program HelloWorld;
begin
cobegin
writeln('hello');
writeln('world');
coend;
end.

COBEGIN/COEND commands represent the concurrent block.
Every statement inside concurrent block will run in a separate process.
Thus in theory the above program has equal chances of printing both "hello world" and "world hello".

Run this program a couple of times to see if it really happens.
It does not, it always print "Hello World" in normal order!
ParaPascal is not really parallel? You have been cheated!

Not really, you just did not set interpreter so you can see this effect properly.
Go to Processors menu and set number of processors to 1, then go to Scheduler menu and set it to RANDOM.

These settings enable you to see the "race effect" much more quickly.

ParaPascal is by default set to simulate 4 processors and since you had only 2 processes (one for "hello" and one for "world") there was no race effect because 2 distinct processors simply executed tasks in the order they got them.
So if you want to see race effect when simulating 4 processors you need at least 5 processes.


Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.