Thomas Haupt
|
AW: Multithreaded resource manager
|
Thomas Haupt
07/09/2008 7:12 AM
post10216
|
AW: Multithreaded resource manager
You'll need to unlock the I/O attribute structure in the OCB
during the 'inactive' period (i.e., while sleeping).
The attribute structure is implicitly locked before entering
and unlocked after leaving your handler functions (at least,
for most of them). This is to automatically ensure only one
thread will access a device at a time.
So while in io_write, your attribute structure is locked --
and the framework tries to aqcuire that lock before entering
io_read, thus getting blocked on a condvar.
To get around this, unlock the attribute structure before
sleeping, and re-lock it when getting busy again:
iofunc_attr_unlock( ocb->attr );
...sleep...
iofunc_attr_lock( ocb->attr );
- Thomas
> -----Ursprungliche Nachricht-----
> Von: bob lipka [mailto:bobik@os.pl]
> Gesendet: 09 July 2008 12:25
> An: ostech-core_os
> Betreff: Multithreaded resource manager
>
>
> I have compiled multithreaded resource manager with io_write
> and io_read procedures, made form code snippets cut exactly
> form Neutrino programmers guide. For testing I have added
> printfs at the beginning of io_read and io_write, with
> sleep(10) after each printf. I attach the source.
>
> I was hoping, that if my write blocks for 10 seconds I still
> be able to read and vice versa, but it does not work like
> this. When one i/o blocks and the other is issued then its
> thread starts, but blocks on some CONDVAR not even reaching
> its io_xxxx function. It gets there only after this first
> thread unblocks from nanosleep and finishes.
>
> What should I do to have this multitheading work
> simultaneously, not one after another?
>
> RobertL
>
> _______________________________________________
> OSTech
> http://community.qnx.com/sf/go/post10215
>
|
|
|