public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] problem with select()
@ 2006-04-02 15:01 Маврин Геннадий
  2006-04-04 10:58 ` Andrew Lunn
  2006-04-05  7:37 ` [ECOS] " Sergei Organov
  0 siblings, 2 replies; 4+ messages in thread
From: Маврин Геннадий @ 2006-04-02 15:01 UTC (permalink / raw)
  To: ecos-discuss

I use the old version of ecos (ecos 2.0 downloaded at December 2003). But I searched the problem I have in the ecos bug tracking database and didn't find it.

I use select() function to wait when the descriptor will be ready for reading. Sometime select() returns 0 (time limit expire) but I am sure that the requested descriptor was ready for reading some time ago. After that if I perform the reading operation with this descriptor it completes successfully.

I think that I know the reason of this problem. The structure of cyg_pselect() function is:

int cyg_pselect( )
{
 while (!error)
 {
  for (mode = 0;  !error && mode < 3;  mode++)
  {
    ...
    // Checking the descriptors to be ready to requested operation
    ...
  }

  ...

  Cyg_Scheduler::lock();
  ...
  // Waiting for cyg_selwakeup() call
  ...
  Cyg_Scheduler::unlock();
 }
}

I think that the descriptor may come ready after the loop which checks the descriptors to be ready to requested operation but before Cyg_Scheduler::lock() function call. In this case cyg_pselect( ) will wait for descriptor even if this descriptor is ready. My idea is to move Cyg_Scheduler::lock() call up.

int cyg_pselect( )
{
 while (!error)
 {
  for (mode = 0;  !error && mode < 3;  mode++)
  {
    Cyg_Scheduler::lock();
    ...
    // Checking the descriptors to be ready to requested operation
    ...
  }

  ...

  // Waiting for cyg_selwakeup() call
  ...
  Cyg_Scheduler::unlock();
 }
}

Is my idea good or not?

Gennady

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [ECOS] problem with select()
  2006-04-02 15:01 [ECOS] problem with select() Маврин Геннадий
@ 2006-04-04 10:58 ` Andrew Lunn
  2006-04-04 14:52   ` Маврин Геннадий
  2006-04-05  7:37 ` [ECOS] " Sergei Organov
  1 sibling, 1 reply; 4+ messages in thread
From: Andrew Lunn @ 2006-04-04 10:58 UTC (permalink / raw)
  To: ?????? ????????; +Cc: ecos-discuss

On Sun, Apr 02, 2006 at 07:01:15PM +0400, ?????? ???????? wrote:

Hi ??????

> I use the old version of ecos (ecos 2.0 downloaded at December
> 2003). But I searched the problem I have in the ecos bug tracking
> database and didn't find it.

Very few bugs get entered into the database. There has been some
discussion about thjis sort of problem in the last few years, so i
suggest you check the email archive and the current source.

        Andrew

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [ECOS] problem with select()
  2006-04-04 10:58 ` Andrew Lunn
@ 2006-04-04 14:52   ` Маврин Геннадий
  0 siblings, 0 replies; 4+ messages in thread
From: Маврин Геннадий @ 2006-04-04 14:52 UTC (permalink / raw)
  To: Andrew Lunn; +Cc: ecos-discuss

I searched the bug in email archive and didn't find it.
I downloaded latest source codes. I have found a list of changes of
select.cxx file in the \ecos\packages\io\fileio\current\ChangeLog file:
2005-10-20  Andrew Lunn  <andrew.lunn@ascom.ch>

	* src/select.cxx: Needs sys/time.h for struct timeval.

2004-12-15  Andrew Lunn  <andrew.lunn@ascom.ch>

	* src/select.cxx (cyg_pselect): We need the oldmask under all
	conditions.

2004-12-01  Alex Paulis and Cameron Taylor  <ctaylor@waverider.com>

	* include/fileio.h: Changed si_thread to si_waitFlag
	* src/select.cxx: Improved efficiency: 1. Only threads waiting
	on a selector are woken up in selwake. This is done by swapping
	the condition variable for an event flag and registering threads
	for wakeup in selrecord. 2. No mutex is now required. 3. Search
	through the FD mask much streamlined.

2004-10-01  Oyvind Harboe  <oyvind.harboe@zylin.com>

        * src/select.cxx: place the CYGBLD_ATTRIB_INIT_PRI such that it
	compiles for gcc 3.4.2 which is more picky about its placement.
	

2004-07-23 Oyvind Harboe <oyvind.harboe@zylin.com>

	* src/select.cxx: now correctly returns from select() on
	e.g. closed file pointers.

2004-01-07  Jonathan Larmour  <jifl@eCosCentric.com>

	* src/select.cxx: No need to make pselect() dependent on
	CYGPKG_POSIX - that would depend on the arguments. Assert instead,
	and more correctly make it contingent on CYGPKG_POSIX_SIGNALS.

2003-12-03  Dan Jakubiec  <djakubiec@yahoo.com>

	* src/select.cxx (pselect): Fixed the pselect() call to correctly
	handle NULL timeout arguments.  The previous implementation would
	cause a random timeout value to be used.

That is all changes since December 2003.
It's looks like my problem was not fixed. From my point of view all versions
(including latest) of cyg_pselect() function don't works correctly.

Gennady

-----Original Message-----
From: Andrew Lunn <andrew@lunn.ch>
To: ?????? ???????? <genamavr@mail.ru>
Date: Tue, 4 Apr 2006 12:58:16 +0200
Subject: Re: [ECOS] problem with select()

> 
> On Sun, Apr 02, 2006 at 07:01:15PM +0400, ?????? ???????? wrote:
> 
> Hi ??????
> 
> > I use the old version of ecos (ecos 2.0 downloaded at December
> > 2003). But I searched the problem I have in the ecos bug tracking
> > database and didn't find it.
> 
> Very few bugs get entered into the database. There has been some
> discussion about thjis sort of problem in the last few years, so i
> suggest you check the email archive and the current source.
> 
>         Andrew
> 

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [ECOS]  Re: problem with select()
  2006-04-02 15:01 [ECOS] problem with select() Маврин Геннадий
  2006-04-04 10:58 ` Andrew Lunn
@ 2006-04-05  7:37 ` Sergei Organov
  1 sibling, 0 replies; 4+ messages in thread
From: Sergei Organov @ 2006-04-05  7:37 UTC (permalink / raw)
  To: ecos-discuss

Маврин Геннадий <genamavr@mail.ru> writes:

[...]

> I think that the descriptor may come ready after the loop which checks
> the descriptors to be ready to requested operation but before
> Cyg_Scheduler::lock() function call. In this case cyg_pselect( ) will
> wait for descriptor even if this descriptor is ready. My idea is to
> move Cyg_Scheduler::lock() call up.
>
> int cyg_pselect( )
> {
>  while (!error)
>  {
>   for (mode = 0;  !error && mode < 3;  mode++)
>   {
>     Cyg_Scheduler::lock();
>     ...
>     // Checking the descriptors to be ready to requested operation
>     ...
>   }
>
>   ...
>
>   // Waiting for cyg_selwakeup() call
>   ...
>   Cyg_Scheduler::unlock();
>  }
> }
>
> Is my idea good or not?

I don't believe it's correct to lock the scheduler multiple times (in
the loop) and then unlock it only once.

-- Sergei.


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-04-05  7:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-02 15:01 [ECOS] problem with select() Маврин Геннадий
2006-04-04 10:58 ` Andrew Lunn
2006-04-04 14:52   ` Маврин Геннадий
2006-04-05  7:37 ` [ECOS] " Sergei Organov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).