Hacker News new | past | comments | ask | show | jobs | submit login

Having the workers acquire the lock and update the terminal themselves seems like it would cause lock contention.

An alternative would be to have only the main process do the updating and have the workers message it about progress, using a queue.




Funny enough Glibc has a lock for threaded printing internally. You can disable the lock in glibc with the __fsetlocking function and the FSETLOCKING_BYCALLER parameter.

I had a threaded server that we were debugging which would only dump state correctly if we deleted a printf right before in a different thread. Really confused me until I figured this out.


This is what I would do. And every process has at least some state output always (so there are no blank lines).


The real life processes take 30+s so contention isn't a big problem




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: