Follow us on Google+ Follow us on Facebook Follow us on Twitter

Opened 7 years ago

Last modified 3 years ago

#281 new enhancement

printf functions are overserialized

Reported by: Jiri Svoboda Owned by:
Priority: major Milestone: 0.7.1
Component: helenos/lib/c Version:
Keywords: Cc:
Blocker for: Depends on:
See also:

Description

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 (4)

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

Milestone: 0.5.00.5.1

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

Type: defectenhancement

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

Milestone: 0.5.00.5.1

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

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