Bug 57014 - Starvation in cyg_libc_stdio_flush_all_but()?
Summary: Starvation in cyg_libc_stdio_flush_all_but()?
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: eCos
Classification: Retired
Component: C library
Version: 1.5.2
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jonathan Larmour
QA Contact: Jonathan Larmour
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2001-12-03 09:44 UTC by Andrew Lunn
Modified: 2007-04-18 16:38 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2001-12-05 09:53:08 UTC
Embargoed:


Attachments (Terms of Use)
Simple test case (1.02 KB, text/plain)
2001-12-03 13:36 UTC, Need Real Name
no flags Details
Here is the patch (2.38 KB, patch)
2001-12-04 23:32 UTC, Jonathan Larmour
no flags Details | Diff

Description Andrew Lunn 2001-12-03 09:44:12 UTC
Description of Problem:

Under some circumstances, my application's UI freezes but background threads
still run. The following scenario causes it to happen:

  1. Two threads; one, called CLI, handles the command line interface. The
     second, say WRK, does some work and prints messages to the console.

  2. priority(CLI) > priority(WRK)    (higher priority, not higher value)

  3. While WRK is printing a message to stdout, the user hits RETURN which
     causes the CLI thread to wake up and display a prompt to stderr. This ends
     in cyg_libc_stdio_flush_all_but() with the CLI thread looping endlessly
     trying to flush stdout since WRK owns stdout stream's lock and cannot
     release it because of its lower priority.


Version-Release number of selected component (if applicable): 1.5.2

Comment 1 Jonathan Larmour 2001-12-03 12:48:20 UTC
[ Ideally I'll need a testcase.... ]

I suspect what is required is to replace the mutex "trylock" with a lock when
going through the loop a second time. This allows mutex priority inheritance to
work properly.

I'll look at it closer. Is this a contractual bug report or a contrib one? I
suspect the former so I'll treat it as such :-).



Comment 2 Andrew Lunn 2001-12-03 13:03:47 UTC
I submitted this with my Ascom Contract hat on.

Comment 3 Need Real Name 2001-12-03 13:36:46 UTC
Created attachment 39408 [details]
Simple test case

Comment 4 Jonathan Larmour 2001-12-04 23:31:52 UTC
It took me a little longer than expected (I got bogged down trying to get debug
hardware to work right), but this should hopefully solve it. I've tried it with
your test case (with the cyg_thread_delay in worker() removed, to give it proper
effect) and it appears happy.

Can you confirm?


Comment 5 Jonathan Larmour 2001-12-04 23:32:43 UTC
Created attachment 39647 [details]
Here is the patch

Comment 6 Need Real Name 2001-12-05 08:24:51 UTC
Yes, the patch solves the problem. Thanks.

Comment 7 Andrew Lunn 2001-12-05 09:53:03 UTC
Great. I checked the patch into our CVS server at Solothurn.


Note You need to log in before you can comment on or make changes to this bug.