locking OCB instead of attribute

Hi,

I’d like to have the OCB locked instead of the attribute structure in my
resource manager. It seems that since the same attribute structure is
shared by whom ever connects to the same “file”, they are prevented from
running cuncurrently. Since the OCB is the only thing that gets modified
during an actual read or write operation (or is it?), wouldn’t it be safe to
lock it instead of the attribute struct, allowing these clients to run in
parallel, if they all issued seperate open()'s on the same mountpoint?
Also, if the attribute sturct still needs a lock, it seems that a shared
lock on the attribute structure (pthread_rwlock_*()) would be preferable to
an exclusive one.

Is it OK to ignore the RSVD in IO_RSVD_OCB_LOCK and provide OCB locking
instead of the default iofunc_attr_lock()? I’m not as experienced as I’d
like to be with resmgrs and any reasons as to why this wouldn’t be such a
good idea, would be appreciated.

Thanks,
Kevin

Kevin Stallard <kevin@fffflyingrobbbotsss.com> wrote:

Hi,

I’d like to have the OCB locked instead of the attribute structure in my
resource manager. It seems that since the same attribute structure is
shared by whom ever connects to the same “file”, they are prevented from
running cuncurrently. Since the OCB is the only thing that gets modified
during an actual read or write operation (or is it?), wouldn’t it be safe to
lock it instead of the attribute struct, allowing these clients to run in
parallel, if they all issued seperate open()'s on the same mountpoint?
Also, if the attribute sturct still needs a lock, it seems that a shared
lock on the attribute structure (pthread_rwlock_*()) would be preferable to
an exclusive one.

Normally stuff in the attribute structure gets modified as well.

But, that isn’t the main reason. The idea is it is a file, and
operations to a file MUST be ordered, because a write() [up to a
certain size] is defined to be an atomic operation – so it must
all go through to the underlying file (whatever that means, but
think of a file on disk for understanding) complete.

Also, some of the things that may get updated in the attribute
structure may include file size, access times, etc.

Even worse, if you’re using the attribute structure to represent
underlieing hardware, e.g. a UART, and you don’t lock the attribute
structure, you may have two different threads trying to access the
same hardware at the same time – this is (almost) always a BAD
thing.

Or, if you have a queue or buffer associated with the hardware, this
again will generally be stored off the attribute structure, and locking
the attribute structure will also lock access to the queue/buffer as
well.

Is it OK to ignore the RSVD in IO_RSVD_OCB_LOCK and provide OCB locking
instead of the default iofunc_attr_lock()? I’m not as experienced as I’d
like to be with resmgrs and any reasons as to why this wouldn’t be such a
good idea, would be appreciated.

So, I would generally suggest sticking with attribute based locking.

In general, this means if you have a single-device resource manager,
there is (little to) no advantage to running the resource manager side
of things multi-threaded (e.g. with a thread pool) though there may still
be some advantage to having threads, for instance a hw interupt servicing
thread.

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.

I know it takes time to respond to these questions, thanks for doing so.

Kevin

“David Gibbs” <dagibbs@qnx.com> wrote in message
news:b81hmg$75l$1@nntp.qnx.com

Kevin Stallard <> kevin@fffflyingrobbbotsss.com> > wrote:
Hi,

I’d like to have the OCB locked instead of the attribute structure in my
resource manager. It seems that since the same attribute structure is
shared by whom ever connects to the same “file”, they are prevented from
running cuncurrently. Since the OCB is the only thing that gets
modified
during an actual read or write operation (or is it?), wouldn’t it be
safe to
lock it instead of the attribute struct, allowing these clients to run
in
parallel, if they all issued seperate open()'s on the same mountpoint?
Also, if the attribute sturct still needs a lock, it seems that a shared
lock on the attribute structure (pthread_rwlock_*()) would be preferable
to
an exclusive one.

Normally stuff in the attribute structure gets modified as well.

But, that isn’t the main reason. The idea is it is a file, and
operations to a file MUST be ordered, because a write() [up to a
certain size] is defined to be an atomic operation – so it must
all go through to the underlying file (whatever that means, but
think of a file on disk for understanding) complete.

Also, some of the things that may get updated in the attribute
structure may include file size, access times, etc.

Even worse, if you’re using the attribute structure to represent
underlieing hardware, e.g. a UART, and you don’t lock the attribute
structure, you may have two different threads trying to access the
same hardware at the same time – this is (almost) always a BAD
thing.

Or, if you have a queue or buffer associated with the hardware, this
again will generally be stored off the attribute structure, and locking
the attribute structure will also lock access to the queue/buffer as
well.

Is it OK to ignore the RSVD in IO_RSVD_OCB_LOCK and provide OCB locking
instead of the default iofunc_attr_lock()? I’m not as experienced as
I’d
like to be with resmgrs and any reasons as to why this wouldn’t be such
a
good idea, would be appreciated.

So, I would generally suggest sticking with attribute based locking.

In general, this means if you have a single-device resource manager,
there is (little to) no advantage to running the resource manager side
of things multi-threaded (e.g. with a thread pool) though there may still
be some advantage to having threads, for instance a hw interupt servicing
thread.

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.

Kevin Stallard <kevin@fffflyingrobbbotsss.com> wrote:

I know it takes time to respond to these questions, thanks for doing so.

You’re welcome.

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.

“David Gibbs” <dagibbs@qnx.com> wrote in message
news:b81hmg$75l$1@nntp.qnx.com

In general, this means if you have a single-device resource manager,
there is (little to) no advantage to running the resource manager side
of things multi-threaded (e.g. with a thread pool) though there may still
be some advantage to having threads, for instance a hw interupt servicing
thread.

What about the need to have a thread available to receive the
unblock pulse? Isn’t this, in itself, a reason to always use
a thread pool? Or is there some other technique to use for
a single-threaded resmgr?

Kirk Bailey

Kirk Bailey <kirk.a.bailey@delphi.com> wrote:

What about the need to have a thread available to receive the
unblock pulse? Isn’t this, in itself, a reason to always use
a thread pool? Or is there some other technique to use for
a single-threaded resmgr?

The “technique” is very simple: you just finish processing the current
request, receive the next message as usual, and if it turns out to be an
unblock pulse, you check whether the client actually is still blocked on
you, and if it is, you reply.