Bug 57014

Summary: Starvation in cyg_libc_stdio_flush_all_but()?
Product: [Retired] eCos Reporter: Andrew Lunn <andrew.lunn>
Component: C libraryAssignee: Jonathan Larmour <jlarmour>
Status: CLOSED CURRENTRELEASE QA Contact: Jonathan Larmour <jlarmour>
Severity: medium Docs Contact:
Priority: medium    
Version: 1.5.2CC: acnrf, alexs
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2001-12-05 09:53:08 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Simple test case
none
Here is the patch none

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.