Opened 13 years ago

Last modified 6 years ago

#281 new enhancement

printf functions are overserialized

Reported by: Jiri Svoboda Owned by:
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 (7)

comment:1 by Jakub Jermář, 13 years ago


comment:2 by Jakub Jermář, 13 years ago

Type: defectenhancement

comment:3 by Jakub Jermář, 12 years ago


comment:4 by Jakub Jermář, 10 years ago


comment:5 by Jiří Zárevúcky, 7 years ago

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

comment:6 by Jakub Jermář, 7 years ago

Milestone: 0.7.1

comment:7 by Jiří Zárevúcky, 6 years ago

Owner: Jiří Zárevúcky removed
Status: assignednew

Haven't actually gotten to this yet. Unassigning for now.

Note: See TracTickets for help on using tickets.