I am new to eCos and so still figuring out how it works. The function unlock_inner is acting as the main mechanism by which context switches occur. An inline wrapper function Cyg_Scheduler::reschedule, as per the comment, is suppose to essentially by a unlock()/lock() sequence whithout actually decrementing the lock count.
1. This seems a bit inaccurate as a unlock()/lock() sequence would not result in thread rescheduling if the lock count was greater than 1 whereas reschedule() seems to allow the possibility of rescheduling. Is the comment right and I am missing something or is my interpretation correct? 2. Inside the Cyg_Scheduler::unlock_inner, DSRs are not run unless the new lock value is 0 (lock going to 0). While this makes sense in general, unlock_inner() never seems to be called unless threads are permitted to be rescheduled so if threads are being rescheduled wouldn't it make sense to have DSRs always run prior to rescheduling in order to minimize the number of context switches (since after the context switch, if the thread switched to restores the lock to 0 the and pending DSRs will be run again and could result in another thread rescheduling). cjmeyer -- Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
