View Single Post
  #12   Spotlight this post!  
Unread 16-06-2014, 00:19
SoftwareBug2.0's Avatar
SoftwareBug2.0 SoftwareBug2.0 is offline
Registered User
AKA: Eric
FRC #1425 (Error Code Xero)
Team Role: Mentor
 
Join Date: Aug 2004
Rookie Year: 2004
Location: Tigard, Oregon
Posts: 486
SoftwareBug2.0 has a brilliant futureSoftwareBug2.0 has a brilliant futureSoftwareBug2.0 has a brilliant futureSoftwareBug2.0 has a brilliant futureSoftwareBug2.0 has a brilliant futureSoftwareBug2.0 has a brilliant futureSoftwareBug2.0 has a brilliant futureSoftwareBug2.0 has a brilliant futureSoftwareBug2.0 has a brilliant futureSoftwareBug2.0 has a brilliant futureSoftwareBug2.0 has a brilliant future
Re: Challenge problem: 'ladder of abstraction' iterative design in FRC

Quote:
Originally Posted by Colby Skeggs View Post
I am well aware of this "solution".
I said "reasonably implement". Your suggestion, as I truly hope you know, pegs CPU usage at 100% and consumes all available processing power. This is not reasonable, except in very specific use cases.

Also, if you try this on the cRIO under Java, you'll notice that it hangs every single thread other than the main thread for the duration, because Squawk does cooperative multitasking and this code has no "Thread.yield()". (It's still a bad idea in C++, of course, but not quite as horrendous.)
By the way efficiency is not relavent to the point that I was trying to make. And if you're doing cooperative stuff, then your implemenatation can just change to:
Code:
void sleep(float len){
    float start=get_time();
    while(get_time()<start+len) yield();
}
This still pegs your CPU, which as I mentioned earlier, is not relevant.