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: EthernetInterface NTPClient mbed-rtos mbed
timeslice.cpp
00001 #include "timeslice.h" 00002 00003 Timeslice::Timeslice(){ 00004 for( register int i = 0; i < __MAX_TIMESLICES__; i++ ) timeslice[ i ] = 0x00; 00005 } 00006 00007 Timeslice::~Timeslice(){ 00008 // do something here 00009 } 00010 00011 uint8_t Timeslice::get_timeslice(){ 00012 for( register uint8_t i = 0x00; i < __MAX_TIMESLICES__; i++ ) 00013 if( timeslice[ i ] == 0x00 ){ 00014 timeslice[ i ] = 0x01; 00015 return( i + 1 ); 00016 } 00017 return( 0x00 ); 00018 } 00019 00020 void Timeslice::return_timeslice( uint8_t ts ){ 00021 if( ts <= __MAX_TIMESLICES__ && ts > 0 ) timeslice[ ts - 1 ] = 0x00; 00022 } 00023 00024 void Timeslice::reset(){ 00025 for( register uint8_t i = 0x00; i < __MAX_TIMESLICES__; i++ ) 00026 timeslice[ i ] = 0x00; 00027 } 00028 00029 uint8_t Timeslice::remain_timeslices( void ){ 00030 uint8_t sum = 0x00; 00031 for( register uint8_t i = 0x00; i < __MAX_TIMESLICES__; i++ ){ 00032 if( timeslice[ i ] == 0x00 ) sum++; 00033 } 00034 return( sum ); 00035 }
Generated on Fri Jul 22 2022 09:19:18 by
1.7.2