home *** CD-ROM | disk | FTP | other *** search
- /*
- * PREMPT.C Version 2.32
- *
- * DLM. Contains code to demonstrate the preemption of disk io as a
- * dynamically loaded smx module. Adapted from ddemo.c.
- *
- * Copyright (c) 1993 Micro Digital Associates, Inc.
- * All Rights Reserved.
- *
- * Authors: Ralph Moore & Ron Schow
- ***********************************************************************/
- #ifdef DLM_MOD
- #include "dlm_core.h"
- #else
- #include "core.h"
- #endif
-
- #include <stdio.h>
-
- /* function prototypes */
-
- #if __cplusplus
- extern "C" {
- #endif
-
- #ifndef DLM_MOD
- void dlm_preempter_main(void);
- #endif
-
- #if __cplusplus
- }
- #endif
-
- /* variables */
- long dlm_preempts; /* preempt task run counter */
-
- /* variables to store ptrs to smx globals */
- SCB_PTR dlm_in_clib;
- ECB_PTR dlm_ticks;
-
-
- /***** PREEMPTER
- * The purpose of this task is to test that disk i/o operations can
- * be preempted by tasks of various lengths. To alter the length of
- * operation, change the dctr initialization value.
- **********************************************************************/
-
- #ifndef DLM_MOD
- void _cdecl dlm_preempter_main(void)
- #else
- void _cdecl main()
- #endif
-
- {
- static char buffer[10]; /* output buffer for this task */
- long dctr;
-
- dlm_in_clib = (SCB_PTR) get_handle("in_clib");
- dlm_ticks = (ECB_PTR) get_handle("ticks");
-
- unlock();
- dlm_preempts = 0;
-
- wr_string(0,9,LIGHTBLUE,BLACK,!BLINK,"PREEMPTER TASK runs = ");
-
- while(count(2, dlm_ticks, INF))
- {
- for(dctr = 100L; dctr; dctr--); /* delay */
- test(dlm_in_clib, INF);
- sprintf(buffer, "%.6ld", ++dlm_preempts);
- signal(dlm_in_clib);
-
- wr_string(24,9,LIGHTBLUE,BLACK,!BLINK,buffer);
- }
- }