PDA

View Full Version : Paralleled tasks in ksh


wpietron
02-27-03, 08:40
SunOS 5.8

Dear gurus,

I have a group of tasks: `task1`, `task2`, `task3`. I do not know how
long it takes to process them. But I know I can paralell them because
they are independent. When the longest task of the group ends I want to
run `task4` because it is based on results of finished `task1`, `task2`
and `task3`. I pay attantion to fact, that I do not know which task is
the longest one.

Have a look at the ascii-pic of the processing I would
like to get:

#################################
--task1-----
--task2--
--task3-----------
--task4-------
|paralelled tasks | task depended|
#################################

Are where any mechanism in ksh that let me do such a processing? I tried
any combination of 'wait', 'exec', '&', '(', ')' but I was not
successful.

Does anybody know any other shells or tools that can enable me such
a processing?

I appreciate any help. Examples would be great.
Thank you in advance.
Wojciech

thebap
02-27-03, 09:51
Are you running these tasks in the Background ?

I've used wait in the past and it worled OK for me, the wait command waits for background processes to complete before continuing :

ie:

==%<=============================
#!/usr/bin/ksh

## Run each task in the background
task1 &
task2 &
task3 &

## Now we wait for the above to finish prior to running task 4
wait

task4

==%<=============================

wpietron
02-27-03, 10:32
Hi,

isn't 'wait' waiting for the last process? I am going to check it out
right now.

Thank you for your help.

thebap
02-27-03, 10:36
Well the man page for wait on my Solaris 8 box indicates wait
as waiting for any background processes I would run within a script.

I've used it under DG Unix , Linux and Solaris so I'd say it works!

wpietron
02-27-03, 10:40
Thank you thebap, it really works. You have
a beer from me in Poland.
wojtek

thebap
02-27-03, 10:44
Nay problemo.

Glad u sorted it.