void user_x( void ) { int i, j; int pid, ppid; char buf1[16], buf2[16]; pid = get_process_info( INFO_PID, 0 ); ppid = get_process_info( INFO_PPID, 0 ); i = itos10( buf1, pid ); j = itos10( buf2, ppid ); write( FD_CONSOLE, "User X running, PID ", 0 ); write( FD_CONSOLE, buf1, i ); write( FD_CONSOLE, " PPID ", 0 ); write( FD_CONSOLE, buf2, j ); write( FD_CONSOLE, "\n", 1 ); for( int k = 0; k < 20 ; ++k ) { write( FD_SIO, "X", 1 ); for( int k2 = 0; k2 < DELAY_STD; ++k2 ) continue; } write( FD_CONSOLE, "User X exiting, PID ", 0 ); write( FD_CONSOLE, buf1, i ); write( FD_CONSOLE, " PPID ", 0 ); write( FD_CONSOLE, buf2, j ); write( FD_CONSOLE, "\n", 1 ); exit(); }
void user_z( void ) { int n; int pid, ppid; char buf1[16], buf2[16]; pid = get_process_info( INFO_PID, 0 ); ppid = get_process_info( INFO_PPID, 0 ); n = itos10( buf1, pid ); pid = n; n = itos10( buf2, ppid ); ppid = n; write( FD_CONSOLE, "User Z running, PID ", 0 ); write( FD_CONSOLE, buf1, pid ); write( FD_CONSOLE, " PPID ", 0 ); write( FD_CONSOLE, buf2, ppid ); write( FD_CONSOLE, "\n", 1 ); for( int i = 0; i < 10 ; ++i ) { write( FD_SIO, "Z", 1 ); for( int j = 0; j < DELAY_STD; ++j ) continue; } write( FD_CONSOLE, "User Z exiting, PID ", 0 ); write( FD_CONSOLE, buf1, pid ); write( FD_CONSOLE, " PPID ", 0 ); write( FD_CONSOLE, buf2, ppid ); write( FD_CONSOLE, "\n", 1 ); exit(); }
static inline void printStatus(uint16 curX, uint16 curY, bool inCmdMode) { // The trailing spaces clears out junky characters! Keep them // Also the 181 and 198 are hybrid boxed drawing chars. Not adding them printCharAt((char) 181, black, 1, 24); printAt(inCmdMode ? " CMD " : " INS ", dark_grey, 2, 24); printAt(itos10(curX - 1), black, 7, 24); printAt(": ", black, 10, 24); printAt(itos10(curY - 5), black, 12, 24); printCharAt((char) 198, black, 16, 24); }
void user_l( void ) { int i; int pid; uint32_t time; char buf[16]; time = get_system_info( SYSINFO_TIME ); i = itos16( buf, time, 1 ); write( FD_CONSOLE, "User L running, initial time ", 0 ); write( FD_CONSOLE, buf, i ); write( FD_CONSOLE, "\n", 1 ); write( FD_SIO, "L", 1 ); for( i = 0; i < 3 ; ++i ) { pid = spawn( user_x ); if( pid < 0 ) { write( FD_CONSOLE, "User L spawn() #", 0 ); pid = itos10( buf, i ); write( FD_CONSOLE, buf, pid ); write( FD_CONSOLE, " failed\n", 0 ); } else { sleep( 0 ); write( FD_SIO, "L", 1 ); } } time = get_system_info( SYSINFO_TIME ); i = itos16( buf, time, 1 ); write( FD_CONSOLE, "User L exiting at time ", 0 ); write( FD_CONSOLE, buf, i ); write( FD_CONSOLE, "\n", 1 ); exit(); }
string ftos(float f) { // Room for the digits, -, '\0', '.' static char buf[FLOAT_DIGITS + 3]; string p = buf + FLOAT_DIGITS + 1; /* points to terminating '\0' */ memset(p, 0, FLOAT_DIGITS + 3); int i = (int) f; f -= i; strcat(p, itos10(i)); strcat(p, "."); f = abs(f); // Clear negativity while(((int) f) != f) { // Pad zeros f *= 10; } strcat(p, itos10((int) f)); return p; }
void user_g( void ) { int i; char buf[16]; write( FD_CONSOLE, "User G (pid ", 0 ); i = itos10( buf, get_process_info( INFO_PID, 0 ) ); write( FD_CONSOLE, buf, i ); write( FD_CONSOLE, ") running\n", 0 ); write( FD_SIO, "G", 1 ); for( i = 0; i < 5; ++i ) { sleep( SECONDS_TO_MS(15) ); write( FD_SIO, "G", 1 ); } write( FD_CONSOLE, "User G exiting\n", 0 ); exit(); }
void user_n( void ) { int i, j; int prio; char buf[16]; prio = get_process_info( INFO_PRIO, 0 ); i = itos10( buf, prio ); write( FD_CONSOLE, "User N running @ ", 0 ); write( FD_CONSOLE, buf, i ); write( FD_CONSOLE, "\n", 1 ); write( FD_SIO, "N", 1 ); for( i = 0; i < 30; ++i ) { for( j = 0; j < DELAY_STD; ++j ) continue; write( FD_SIO, "N", 1 ); } write( FD_CONSOLE, "User N exiting\n", 0 ); exit(); }
void user_k( void ) { int i; int pid; char buf[16]; write( FD_CONSOLE, "User K running\n", 0 ); write( FD_SIO, "K", 1 ); for( i = 0; i < 3 ; ++i ) { pid = spawn( user_x ); if( pid < 0 ) { write( FD_CONSOLE, "User K spawn() #", 0 ); pid = itos10( buf, i ); write( FD_CONSOLE, buf, pid ); write( FD_CONSOLE, " failed\n", 0 ); } else { sleep( SECONDS_TO_MS(30) ); write( FD_SIO, "K", 1 ); } } write( FD_CONSOLE, "User K exiting\n", 0 ); exit(); }
void user_j( void ) { int i; int pid; char buf[16]; write( FD_CONSOLE, "User J running\n", 0 ); write( FD_SIO, "J", 1 ); for( i = 0; i < N_PROCS * 2 ; ++i ) { pid = spawn( user_y ); if( pid < 0 ) { write( FD_SIO, "j", 1 ); write( FD_CONSOLE, "User J spawn() #", 0 ); pid = itos10( buf, i ); write( FD_CONSOLE, buf, pid ); write( FD_CONSOLE, " failed\n", 0 ); } else { write( FD_SIO, "J", 1 ); } } write( FD_CONSOLE, "User J exiting\n", 0 ); exit(); }