[interfacekit] Re: BScreen (again)
- From: "Ingo Weinhold" <bonefish@xxxxxxxxxxxxxxx>
- To: interfacekit@xxxxxxxxxxxxx
- Date: Mon, 28 Jul 2003 18:37:09 +0200 CEST
On Mon, 28 Jul 2003 18:10:34 +0200 CEST "Axel Dörfler" <axeld@pinc-
software.de> wrote:
> "Ingo Weinhold" <bonefish@xxxxxxxxxxxxxxx> wrote:
> > BPrivateScreen seems to have a sem_id member, which is acquired in
> > WaitForRetrace() -- if not yet initialized, the method gets the
> > sem_id
> > from the app server. I suspect, all threads of all applications
> > wait
> > on
> > the same semaphore for the vertical blank. I wonder a bit, how this
> > works, but probably there is something like an undocumented
> > release_sem_etc() flag that releases the semaphore exactly as often
> > as
> > necessary to unblock all waiting threads.
>
> What about this:
>
> int32 *sWaitForRetraceWaiters = locationInSomeSharedMemory;
> sem_id sRetraceSemaphore;
>
> status_t
> WaitForRetrace()
> {
> atomic_add(sWaitForRetraceWaiters, 1);
> return acquire_sem(sRetraceSemaphore);
> }
>
>
> and in the driver:
>
> int32 waiters = atomic_and(sWaitForRetraceWaiters, 0);
> release_sem_etc(sRetraceSemaphore, waiters);
>
> ?
> Not tested, but it should work safely AFAICT.
Yep, looks good in principle, but it may have problems, since
acquire_sem() is actually an acquire_sem_etc() with timeout. Which will
cause the counter and the semaphore counter to get out of sync. As in
BLocker I don't think it is possible to fix this (not without a further
semaphore at least).
CU, Ingo
- Follow-Ups:
- [interfacekit] Re: BScreen (again)
- From: Axel Dörfler
- References:
- [interfacekit] Re: BScreen (again)
- From: Axel Dörfler
Other related posts:
- » [interfacekit] BScreen (again)
- » [interfacekit] Re: BScreen (again)
- » [interfacekit] Re: BScreen (again)
- » [interfacekit] Re: BScreen (again)
- » [interfacekit] Re: BScreen (again)
- » [interfacekit] Re: BScreen (again)
- » [interfacekit] Re: BScreen (again)
- » [interfacekit] Re: BScreen (again)
- » [interfacekit] Re: BScreen (again)
- » [interfacekit] Re: BScreen (again)
- » [interfacekit] Re: BScreen (again)
- » [interfacekit] Re: BScreen (again)
- » [interfacekit] Re: BScreen (again)
- » [interfacekit] Re: BScreen (again)
- [interfacekit] Re: BScreen (again)
- From: Axel Dörfler
- [interfacekit] Re: BScreen (again)
- From: Axel Dörfler