This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: problem with select()


>> 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.

It's my mistake. I have changed the structure of cyg_pselect() function
as follow:
int cyg_pselect( )
{
  ...
  Cyg_Scheduler::lock();
  while (!error)
  {
   for (mode = 0;  !error && mode < 3;  mode++)
   {
     ...
     // Checking the descriptors to be ready to requested operation
     ...
   }

   ...

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

I am not sure that it's a good solution but now select( ) function works
fine from my point of view.

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]