Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: EALib EthernetInterface_vz mbed-rtos mbed
Fork of header_main_colinas_V0-20-09-14 by
timeslice.cpp
00001 #include "timeslice.h" 00002 00003 Timeslice::Timeslice(){ 00004 for( register int i = 0; i < MAX_TIMESLICES; i++ ) timeslice[ i ] = 0; 00005 } 00006 00007 Timeslice::~Timeslice(){ 00008 // do something here 00009 } 00010 00011 uint8_t Timeslice::get_timeslice(){ 00012 for( register uint8_t i = 0; i < MAX_TIMESLICES; i++ ) 00013 if( timeslice[ i ] == 0 ){ 00014 timeslice[ i ] = 1; 00015 return( i + 1 ); 00016 } 00017 return( 0 ); 00018 } 00019 00020 void Timeslice::return_timeslice( uint8_t ts ){ 00021 if( ts <= MAX_TIMESLICES && ts > 0 ) timeslice[ ts - 1 ] = 0; 00022 } 00023 00024 void Timeslice::reset(){ 00025 for( register uint8_t i = 0; i < MAX_TIMESLICES; i++ ) 00026 timeslice[ i ] = 0; 00027 } 00028 00029 uint8_t Timeslice::remain_timeslices( void ){ 00030 uint8_t sum = 0; 00031 for( register uint8_t i = 0; i < MAX_TIMESLICES; i++ ){ 00032 if( timeslice[ i ] == 0 ) sum++; 00033 } 00034 return( sum ); 00035 }
Generated on Tue Jul 12 2022 16:25:13 by
