LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-17-2007, 09:43 AM   #1
ik_nitk
LQ Newbie
 
Registered: Jan 2006
Posts: 12

Rep: Reputation: 0
Forking in Makefile ! How ?


I have some directories which have source code. the source code in that directory are independent of each other. All are dependent on one single common/main directory.
In each directory there is one Makefile which will generate .so (dynamic lib file).


There is one main Makefile which will initiate or call make command in subdirectories.

Since it calls sequentially the time taken is more.

i want to call them simultaneously so the job (or compilation completes faster)


for example: current Makefile [Note : not exact makefile , just an example]

DIR1/make
DIR2/make

gcc *.c DIR1/xx.so DIR2/yy.so

if fork the make command like this.....

DIR1/make &
DIR2/make &

#i want to wait here for them to complete but dont know how

gcc *.c DIR1/xx.so DIR2/yy.so



..........
my question :

can any one tell me how can i wait for the process to complete when it is run in the background.

Or rather

How to know if the background process is finished
 
Old 01-17-2007, 11:01 AM   #2
mackdav
Member
 
Registered: Feb 2005
Distribution: RHEL, CentOS
Posts: 113

Rep: Reputation: 16
If your streams are really independent, you can have make run multiple forks with the -j parameter. It should split off concurrent processes and then wait at the bottom for the two dependencies to finish before running the final command.

eg:

$ make -j 4 all

Note that this may not in fact make things go any faster since most compiles are disk-bound, not CPU-bound; so having more processes means that more processes are sitting around waiting for disk i/o, and with the additional context switches the computer has to do it may result in a slower compile.

If you have a really large job to do (say for example the kernel) and you have a bunch of machines with identical OS installations, you might look into something like distcc which farms out gcc jobs to other computers.
 
Old 01-18-2007, 08:24 AM   #3
ik_nitk
LQ Newbie
 
Registered: Jan 2006
Posts: 12

Original Poster
Rep: Reputation: 0
Thanks

Quote:
Originally Posted by mackdav
If your streams are really independent, you can have make run multiple forks with the -j parameter. It should split off concurrent processes and then wait at the bottom for the two dependencies to finish before running the final command.

eg:

$ make -j 4 all

Note that this may not in fact make things go any faster since most compiles are disk-bound, not CPU-bound; so having more processes means that more processes are sitting around waiting for disk i/o, and with the additional context switches the computer has to do it may result in a slower compile.

If you have a really large job to do (say for example the kernel) and you have a bunch of machines with identical OS installations, you might look into something like distcc which farms out gcc jobs to other computers.
Ya thats true i never thought of that
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
automake, makefile, makefile.in and makefile.am Fond_of_Opensource Linux - Newbie 1 09-12-2006 08:35 PM
what is the meaning of Makefile,Makefile.am,Makefile.in cynthia_thomas Linux - General 3 12-08-2005 05:00 AM
how to get (makefile -f makefile )output into the textview widget in Pygtk sailu_mvn Programming 3 02-28-2005 03:57 AM
generate Makefile from Makefile.in without calling ./configure ? chris78 Programming 2 05-02-2004 12:23 PM
Forking and multiprocessors sniff Programming 4 02-18-2003 05:28 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:50 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration