home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: SysTools / SysTools.zip / cron093.lzh / CRON.DOC < prev    next >
Text File  |  1992-10-07  |  5KB  |  120 lines

  1.  
  2.   cron.exe 0.90 (BETA) - a clock daemon for OS/2 2.0
  3.  
  4.   Designed and written by Ken Miller - 1:134/111
  5.   Copyright (c) 1992 Shetland Computer Services
  6.  
  7.   -------------------------------------------------------------------------
  8.  
  9.   cron is an OS/2 implementation of the Unix utility cron.  Based on a
  10.   crontab file (a listing of times, dates, and programs to run) cron
  11.   will schedule these jobs to run at their designated times.  cron is
  12.   not an exact duplicate of the Unix cron - some liberties have been
  13.   taken, so please be sure to look at the example source file for the
  14.   differences.
  15.  
  16.   Setting up cron is very simple.  In your startup.cmd, use the start
  17.   command to start cron.  Use something like this:
  18.  
  19.   start "CRON - Clock Daemon" /win /c c:\bin\cron.exe c:\bin\crontab
  20.  
  21.   This command will start cron as a full screen session, and read in
  22.   c:\os2bin\crontab and immediately start processing.
  23.  
  24.   NOTE: do not use RUN= in your config.sys or DETACH from the command
  25.         line.  These two techniques do not work (yet), and are not
  26.         supported.
  27.  
  28.   How does it work?
  29.   ----------------
  30.  
  31.   The 'simple' way of writing a program like this is to write a polling
  32.   loop, which loops until an event is ready to run.  Under OS/2, a
  33.   program like this would be an absolute pig, since it would fully use
  34.   all of its alloted time *every* cpu slice.  Most programs, when
  35.   properly written, do NOT require the CPU all the time.
  36.  
  37.   Enter threads, queues, and semaphores.  OS/2 has implemented some nice
  38.   features that do not exist in current flavours of Unix (other than the
  39.   Mach kernal), such as threads and semaphores.  These options allow a
  40.   program to efficiently use the cpu without to much grief on the part
  41.   of the programmer.
  42.  
  43.   cron is a two-thread program.  Thread-1, which is always the 'main'
  44.   thread of any OS/2 program, runs the scheduler.  An asyncronous
  45.   one-shot timer is created which lasts for 1 minute.  Every minute
  46.   thread-1 checks to see if there are any jobs to run.  Once the check
  47.   has completed, another async timer is created, and so on.
  48.  
  49.   If an event is found to run, thread-1 does not spawn a process to run
  50.   the program, since this can take upwards of 1-2 seconds to perform.
  51.   Instead, a message is written to a queue.
  52.  
  53.   Thread-2 spends most of its time sleeping.  When cron is started,
  54.   thread-2 is created, and it immediately sees if is has any programs to
  55.   spawn (it does this by reading a process queue).  If nothing is in the
  56.   queue, thread-2 goes to sleep.
  57.  
  58.   When thread-1 writes something to the queue, thread-2 wakes up, reads
  59.   the queue, and spawns off the process.  It the reads the queue again,
  60.   and so the process continues (or is that thread?).
  61.  
  62.   So, what you get is a thread which wakes up every minute, scans an
  63.   internal list, and sends messages to thread-2 to spawn off processes.
  64.   If you run pulse.exe, and the run cron, you should hardly notice any
  65.   impact on your system, since cron spends almost 99% of the time
  66.   sleeping. However, if you are spawning off lots of jobs, you will of
  67.   course cause some impact.  This isn't cron's fault - it's the creation
  68.   of new processes which takes time.
  69.  
  70.   Future Plans:
  71.   ------------
  72.  
  73.   Well, there is only so far you can take a program like cron.  It is
  74.   basically a finished product, but there are a few things to add to it:
  75.  
  76.     i) better explanation of error codes returned from the spawn of the
  77.        specified processes.  rc=2 just isn't self explanatory.
  78.  
  79.    ii) disable killing the program via the keyboard.  If this is to be a
  80.        true daemon, you should not be able to kill this program with
  81.        SIGINTs.
  82.  
  83.   iii) instead of being a 'startable' process, it should be a
  84.        'detach'able process.  Right now, this program does not work
  85.        properly when detached.  This is currently being investigated.
  86.  
  87.    iv) perhaps a change in the cron grammar to allow crontab entries to be
  88.        split across two lines, to make the file easier to read.
  89.  
  90.     v) this one is left open for you.  If you have any suggestions,
  91.        please feel free to drop me a line.  I can't promise anything,
  92.        but I will look at all sugestions.
  93.  
  94.   How much does it cost?
  95.   ---------------------
  96.  
  97.   As a rather well-known PC Fractal programming team says,
  98.  
  99.     "Don't want money.  Got money.  Want admiration".
  100.  
  101.   This program is free, but it is not freeware - it is shareware. This
  102.   means that while you can use the program for free (since I don't want
  103.   any money) the program does remain the intellectual property of Ken
  104.   Miller and Shetland Computer Services.  It is meant for use only in
  105.   non-commerical environments. If you wish to use this program in a
  106.   commerical environment, contact Ken Miller at 1:134/111 (FidoNet).
  107.  
  108.   Oh, if you do use this program, I'd appreciate it if you would drop me
  109.   a line and let me know! Feel free to give this program to other
  110.   people.  They might find it useful!
  111.  
  112.   Disclaimer
  113.   ----------
  114.  
  115.   Ken Miller and Shetland Computer Services will not be held responsible
  116.   for any damage caused by the use of cron, either directly or
  117.   indirectly.  You use the program at your own risk!
  118.  
  119.  
  120.