| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | DOS OS/2 Advice ?? |
LA> Got any ideas ? What I want is that secret Int call that OS/2
LA> will treat as an instruction to take the rest of the slice
LA> away...but don't put me so far to sleep that I can't wake up
LA> again without keyboard intercession.
I wrote a DOS program to test this. I put this program in a window, and
had PULSE running so that I could observe the effect.
It will probably be a two part message, sorry.
/*
TIMESLIC.C
This program demonstrates the use of releasing timeslices back
to a multi-tasking system.
1. The first display uses maximum cpu cycles.
2. The second display is a wait loop after releasing cycles back to
the system. The user ends the program by hitting anykey.
3. Use the Pulse display window to view results.
*/
#include // Req'd for the isdigit function
#include
#include
#include // Req'd for the time functions
void GetInput ( void ) ;
void PutCursor ( int, int ) ;
int RunningUnderDPMI ( void ) ;
void ReleaseTimeSlice ( void ) ;
char TimeGrid[16] ;
int InDPMI = 0 ;
int Row = 8 ;
int Col = 8 ;
int FirstTime = 1 ;
int BlockTime ;
int Delay ;
union REGS regs ;
void main ( int argc, char * argv[] )
{
// Check for any input arguments
if ( argc )
{
// Check for valid number
if ( isdigit ( (int)argv[1] ) )
Delay = atoi( argv[1] );
else
Delay = 15 ;
} // End-if: argc
// Check for DPMI
InDPMI = RunningUnderDPMI() ;
// Get input loop w/out releasing timeslices, for 15 seconds
GetInput () ;
--FirstTime ;
// Release timeslices and wait for input
GetInput () ;
}
// Get input
void GetInput ( void )
{
int i, j ;
time_t BeginTime, TimeNow ;
double Diff, PrevDiff ;
// Initialize the display buffer
for ( i = 0 ; i < 15 ; i++ ) TimeGrid[i] = 0xb1 ;
TimeGrid[i] = '\0' ;
// Set the cursor position and display the TimeGrid msg and buffer
PutCursor ( Row, Col ) ;
if ( FirstTime )
{
printf ( "%s%d%s", "This display uses max cpu for
", Delay, " seconds" )
Row += 2 ;
PutCursor ( Row, Col ) ;
printf ( "%s", TimeGrid ) ;
// Get the current time
time ( &BeginTime ) ;
// Calculate number of seconds per TimeGrid "block": modulo-15
BlockTime = Delay / 15 ;
// Loop for DELAY seconds, displaying updated time grid
for ( PrevDiff = Diff = i = j = 0 ; Diff < Delay ; )
{
// Get the current time; calculate elapsed time, in seconds
time ( &TimeNow ) ;
Diff = difftime ( TimeNow, BeginTime ) ;
// Check for each 1 second interval
if ( Diff > PrevDiff )
{
// Update previous time difference
PrevDiff = Diff ;
// Count seconds per each "block" of the display grid
j++ ;
// Check for # of seconds for each "block"
if ( j >= BlockTime )
{
// Update the TimeGrid display buffer
TimeGrid [i] = 0xdb ;
j = 0 ;
i++ ;
// Set the cursor position; display the TimeGrid buffer
PutCursor ( Row, Col ) ;
printf ( "%s", TimeGrid ) ;
} // end-if j
} // end-if Diff
} // end-for Delay loop
// Make certain that all of the TimeGrid "blocks" have been filled
if ( i < 14 && BlockTime != 0 )
{
// Update the TimeGrid display buffer
TimeGrid [i] = 0xdb ;
// Set the cursor position and display the TimeGrid buffer
PutCursor ( Row, Col ) ;
printf ( "%s", TimeGrid ) ;
}
} // end-if FirstTime
// Release timeslices; wait for keystroke
else
{
// Put out message
Row += 2 ;
PutCursor ( Row, Col ) ;
printf ( "%s", "Timeslices have been released to the
system" ) ;
Row += 2 ;
PutCursor ( Row, Col ) ;
printf ( "%s", "Keyboard wait loop, ANYKEY to exit" ) ;
// Release time to the system
ReleaseTimeSlice () ;
// Wait for keystroke
while (!kbhit());
}
} // end-GetInput
// Position the cursor
void PutCursor ( int r, int c )
{
regs.h.ah = 2 ;
regs.h.dh = r ;
regs.h.dl = c ;
regs.h.bh = 0 ;
int86 ( 0x10, ®s, ®s ) ;
}
// Check for DMPI: non-zero if DPMI exists
int RunningUnderDPMI(void)
{
int Flag;
regs.x.ax = 0x1687 ;
int86 ( 0x2f, ®s, ®s ) ;
Flag = regs.x.flags ;
// if Flag == 0 then DPMI is installed...
return !Flag;
}
// Release a time slice to a DPMI server
void ReleaseTimeSlice(void)
{
if ( InDPMI )
{
regs.x.ax = 0x1680 ;
int86 ( 0x2f, ®s, ®s ) ;
}
}
___
X OLX 1.53 X OS/2 is a bowl of cherries. Windows is the pits!
--- Maximus/2 3.01
* Origin: Pebble BBS (1:202/1207)SEEN-BY: 50/99 270/101 620/243 625/160 711/401 409 410 413 430 808 809 934 SEEN-BY: 711/955 712/407 515 624 628 713/317 800/1 @PATH: 202/1207 270/101 712/515 711/808 934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.