× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On Mon, 16 Jan 2006, Scott Klement wrote:

Somewhere in the guts of the operating system (or maybe this part is in
hardware, not sure) there's a big loop that loops through all of the
active jobs. As each job comes up in the loop, it gives that job a certain
amount of time to execute code (a "timeslice") before moving on to the
next job.

In the linux world this loop is called the scheduler. There is quite a bit of interesting reading regarding different ways of implementing the scheduler. lwn.net is a good source for reading up on it. Obviously the linux scheduler and the iSeries equivalent won't be the same, but for the curious it is quite interesting.

There's one option that I haven't seen discussed...  setitimer().  You
could use that with a signal handler to have a subprocedure that's run at
a given interval. This might be an interesting option if you need to run
things on a given interval, such as 2 minutes.

Using sleep() won't do that.  If you sleep for 120 seconds, then run a
porgram, then sleep for 120 seconds, does the program run every 2 minutes?
No, because the program takes time to execute.  For example, if the
program takes 30 seconds to run, then it's being run every 2:30.  Two
minutes for the sleep, and 30 seconds for the program itself to run.

If you used setitimer() it would actually run every 2 minutes instead of
2:30 because the signal handler gets called every 2 minutes without regard
to what it does in between.  (Unless, of course, it's runtime actually
exceeds the interval time...  for example, if you called a program that
took longer than 2 minutes...)

Actually I coded up an example that uses setitimer() and also avoids the problem discussed in the paragraph above. My example also uses signals to terminate the program gracefully. My example is in C but you could call RPG subprocedures from the C code to do what you want. My example is here:

http://archive.midrange.com/c400-l/200511/msg00007.html

James Rich

It's not the software that's free; it's you.
        - billyskank on Groklaw

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.