for(delay = 0; delay < transfer->dev->afterstart; delay++); afterstart is loop's limit, which determines the desired delay length, known by definition
El mié, 24 mar 2021 a las 14:57, Johnny Billquist (<b...@softjar.se>) escribió: > Well. There was nothing in there that showed me that afterstart == 0. Is > this a known fact, or an assumption? > > Johnny > > On 2021-03-24 21:47, Grr wrote: > > Since afterstart = 0, there should be no loop to optimize out except ONE > > value test > > > > One hundred cycles for that would seem excessive for me > > > > TWENTY THOUSAND CYCLES for a _zero_ loop?!? > > > > Maybe in Java > > > > > > > > El mié, 24 mar 2021 a las 14:30, Gregory Nutt (<spudan...@gmail.com>) > > escribió: > > > >> > >>> Weird behavior: > >>> > >>> Simply changing loop counter variable from uint16_t to volatile > uint16_t > >>> causes initial delay (with variable delay = 0) going from ~500 ns to > >> ~120 us > >>> > >>> The code is > >>> > >>> uint16_t delay; > >>> > >>> select_function(); > >>> for(delay = 0; delay < transfer->dev->afterstart; delay++); > >>> > >>> Any ideas? > >>> > >> I imagine that the delay loop is no longer being optimized out. That is > >> what volatile is supposed to do (people often don't understand that, it > >> is a great interview question). > >> > > > > -- > Johnny Billquist || "I'm on a bus > || on a psychedelic trip > email: b...@softjar.se || Reading murder books > pdp is alive! || tryin' to stay hip" - B. Idol >