This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
stdio
- To: ecos-discuss <ecos-discuss at sources dot redhat dot com>
- Subject: [ECOS] stdio
- From: "Joerg Troeger" <jtroeger at nortelnetworks dot com>
- Date: Wed, 6 Sep 2000 10:42:57 +0100
- Organization: NetServe
- Reply-To: "Joerg Troeger" <jtroeger at nortelnetworks dot com>
Some remarks to the current stdio implementation:
1.) It is not possible to read two files in parallel.
A console task calls fgetc() to fetch characters from unbuffered stdin
(/dev/tty0).
This calls refill_read_buffer(), which locks the stream_lock variable of
stdin
and waits for input. Another thread calls fread() to read some data from a
file
on the ram disk. fread() calls read() which calls
cyg_libc_stdio_flush_all_but(this).
In cyg_libc_stdio_flush_all_but() there is a loop, which tries to lock and
flush all other streams. This lock fails for stdin (because it is already
locked by the
console thread), and thus the loop is never finished - the task is busy all
the time.
To avoid the lock of already locked streams I have added an inline member
function
last_buffer_op_was_read(), which returns the value of this stream member
variable.
Before calling trylock() in cyg_libc_stdio_flush_all_but (fflush.cxx, rev.
1.1, line #90)
this function can be called. If it returns true, locking the stream and call
flush_output_unlocked() is not necessary.
2.) fread() returns at maximum 128 bytes (fread.cxx, rev. 1.1).
3.) fgets() is actually only another fread() (fgets.cxx, rev. 1.1).
4.) unlock_me() missing in stream.cxx rev 1.1, line #409, #481
5.) Cyg_libc_stdio_files::unlock() missing in fopen.cxx rev. 1.1, lines
#141, #157
and fclose.cxx rev. 1.1, lines #86, #95
6.) return statement missing in fopen.cxx, rev. 1.1 line #245
Jörg Tröger