Fork us on GitHub Follow us on Google+ Follow us on Facebook Follow us on Twitter

Opened 8 years ago

Last modified 8 months ago

#281 assigned enhancement

printf functions are overserialized

Reported by: Jiri Svoboda Owned by: Jiří Zárevúcky
Priority: major Milestone:
Component: helenos/lib/c Version:
Keywords: Cc:
Blocker for: Depends on:
See also:


Prior to changeset:mainline,791 vprintf() (uspace/lib/c/generic/io/vprintf.c) guarded the call to printf_core() with async_serialize(). Now it uses a global fibril mutex.

This is slightly better, but still not good enough. Mutual exclusion, if any, should only be done per stream. The global lock incurs unnecessary (and potentially dangerous) dependencies between fibrils writing to completely different streams (e.g. to console and to a network socket, when we have sockfs).

Actually, do we really want to ensure mutual exclusion for printf (on a specific stream)? AFAICT this is just a workaround for the fact that stream I/O functions are not fibril-safe.

If we add the missing locking to stream I/O functions, we can drop the mutex from vprintf() altogether. The worst that could happen when multiple fibrils called printf() in parallel would be that the outputs would be intermixed, which is, IMO, acceptable.

If an application needs to ensure that output of different fibrils is not intermixed, it should employ its own locking.

Change History (6)

comment:1 Changed 7 years ago by Jakub Jermář


comment:2 Changed 7 years ago by Jakub Jermář

Type: defectenhancement

comment:3 Changed 6 years ago by Jakub Jermář


comment:4 Changed 4 years ago by Jakub Jermář


comment:5 Changed 9 months ago by Jiří Zárevúcky

Owner: set to Jiří Zárevúcky
Status: newassigned

comment:6 Changed 8 months ago by Jakub Jermář

Milestone: 0.7.1
Note: See TracTickets for help on using tickets.