FS#10130 - Concurrent backlight function calls from backlight timeout settings menu
Opened by Boris Gjenero (dreamlayers) - Tuesday, 14 April 2009, 03:37 GMT
Last edited by Boris Gjenero (dreamlayers) - Friday, 01 May 2009, 04:22 GMT
When changing the currently used backlight timeout setting, backlight_update_state() is called from outside backlight_thread(). That function call may lead to target specific backlight on/off and LCD enable/sleep/awake functions. If these functions allow other threads to run (eg. via sleep() or yield()), another concurrent call may happen from backlight_thread().
To see the problem on the 5G iPod, turn the backlight off by scrolling to "Off" on the currently used backlight timeout setting menu, wait for the backlight to fade out, and then turn on the backlight by scrolling down. Over half the time, brightness will be incorrect. For example if brightness is set to 5, the backlight may turn on at brightness 1. This is because of the sleep in _backlight_hw_enable() in backlight-nano_video.c. Other targets have sleep calls in code that runs for lcd_enable(true), and executing multiple copies of that concurrently can't be good.
I discovered this while working on
1) Use mutexes or other means to prevent problems in target-specific code
2) Ensure all calls of target-specific code happen from backlight_thread()
I prefer 2) because it is less prone to bugs.
(Behaviour confirmed with r20696)
Friday, 01 May 2009, 04:22 GMT
Reason for closing: Fixed
Additional comments about closing: Fixed in r20778 and r20834.