On Thu, May 20, 2021 at 08:53:34PM +0200, Volker Rümelin wrote: > > On Fri, May 14, 2021 at 08:03:20PM +0200, Volker Rümelin wrote: > > > The comment above the yield() function suggests that yield() > > > allows interrupts for a short time. Currently this is only true > > > if seabios was built without CONFIG_THREADS or if yield() is > > > called from the main thread. Change the code to always call > > > check_irqs() in yield(). > > I'm confused about the failure scenario you describe here, as yield() > > really should always allow irqs to run prior to returning. When > > called from a "background thread" it will not directly enable irqs, > > but it will always cycle through all "threads" before returning. Thus > > the "main thread" should always be reached and when it runs yield() it > > will permit irqs to run. > > > > Am I missing something? > > Hi Kevin, > > the main thread calls run_thread() to create a background thread, adds it > behind main thread in the thread list and immediately executes the > background thread until the background thread calls yield(). All background > threads in the thread list run in sequence and call yield() until the last > background thread yields to main thread. The main thread has not reached > wait_threads(), which means it will create another background thread and run > it. This will repeat until all background threads are created. You can see > until now the main thread did not call yield() but the background threads > ran several times. The main thread calls yield() for the first time in > wait_threads().
Thanks. It does seem the code is not doing what was intended. Could we add the check to the bottom of run_thread() though? Something like: if (cur == &MainThread) // Permit irqs to fire check_irqs(); -Kevin _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-le...@seabios.org