not sure that C is really the language of multithreading...
getting it right is complicated... really, there is the painter thread, which renders the state, and then there is the input thread, which reacts to user input and alters the painter's data set
coroutines are pretty good for doing this but honestly if i was designing a proper GUI system I'd be making two dedicated threads with the render worker and the painter, the painter needs to be top priority and the render worker needs to be keyed directly to input
it's one of the weaknesses of coroutine scheduling, it is by nature random and frames are regular
rendering interfaces is still a struggle i guess... making them shiny is a real black art