- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Parallel Programming with Perl
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2006 09:22 PM
02-05-2006 09:22 PM
I want to write a programm, which should run a command, count 15 minutes and check the status. If the command is still running, it should be canceled.
However, I found out, that waiting 15 mins with sleep() doesn't bring anything, since it runs in the same thread.
What would be a nice approach to implement an independant clock?
Running it in a parallel thread is ok, but only if the machine has multiple CPU's. Otherwise threads are run one after the other.
Solved! Go to Solution.
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2006 09:28 PM
02-05-2006 09:28 PM
SolutionYou can probably use Parallel-ForkManager to start with.
http://search.cpan.org/~dlux/Parallel-ForkManager-0.7.5/ForkManager.pm
-Arun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2006 09:33 PM
02-05-2006 09:33 PM
Re: Parallel Programming with Perl
Also, this link http://www.unix.org.ua/orelly/perl/prog3/ch17_01.htm
-Arun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2006 09:43 PM
02-05-2006 09:43 PM
Re: Parallel Programming with Perl
the process will then receive an ALARM signal after that time, but the process can do whatever it wants in thr meantime.
# perldoc -f alarm
will describe it, and supply you with an example
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2006 09:47 PM
02-05-2006 09:47 PM
Re: Parallel Programming with Perl
http://earth.e-raist.com/~raistlin/coding.html
You need to create an independent child process
http://bfr.caseywest.com/archives/005438.html
The child must be independent of its parent and run regardless of the status of the parent.
Be careful you can really tie up a system with this.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2006 10:59 PM
02-05-2006 10:59 PM
Re: Parallel Programming with Perl
Using Alarm is a geat suggestion, but is in this particular example, why not go for the standard 'fork'.
Specifically used the forked thread to run the main code. The parent receives the pid for the child and can poke and prod it after sleeping for a while.
> Be careful you can really tie up a system with this.
Not with a simple fork.
> Running it in a parallel thread is ok, but only if the machine has multiple CPU's. Otherwise threads are run one after the other.
Not true. _every_ OS scheduler knows how to run more than 1 thread, making it seem like there is more than one cpu. It does this first and foremoste by exploiting wait time (your sleep, newtowrok wait, disk wait). But even if those threads are 100% cpu bound (not your case), it can and will timeslice to allow more tahn one thread a slice of cpu time.
Cheers,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2006 11:38 PM
02-06-2006 11:38 PM
Re: Parallel Programming with Perl
system() waits for the call, exec() ends the current script, and qw() does the same as system().
Do I have any other alternative here?
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2006 11:54 PM
02-06-2006 11:54 PM