[Click] write handler synchronization
Eddie Kohler
kohler at cs.ucla.edu
Thu Nov 13 12:40:22 EST 2008
Roman Chertov wrote:
> Hi Eddie,
>
>> Normally run_task will NOT execute in parallel with a write handler.
>> Write handlers are by default "exclusive," meaning that all threads
>> are paused before the write handler executes.
>
> Does this mean that if I have say 4 threads in kernel level then all 4
> would be blocked until a call to a write handler is made through the
> click fs?
Yes, all threads are blocked while the write handelr is called.
> I am creating an element that takes a scenario file for a
> link and adds loss and bit corruption. I need the user app to
> periodically generate and load new events into the Click element via
> clickfs. There are at least two event vectors with one being available
> to be populated with events through clickfs, and the other is used by
> the Click element itself. When the Click element exhausts all the
> events in the current vector it then swaps the vectors, so that the just
> exhausted vector becomes available for writing to by the user app. So I
> am concerned about synchronization (which seems to be not an issue). But
> this raises a problem of all of the tasks blocking for the duration of
> the update. Is there a way to avoid this? I wouldn't mind writing the
> synchronization code to avoid the potentially lengthy block.
Yes. Simply mark the handler as NONEXCLUSIVE using the Handler::NONEXCLUSIVE
flag. Then you'll need to handle synchronization, but the handler won't block.
Eddie
>
> Thanks,
>
> Roman
>
>>
>> Note that this ONLY applies to write handlers accessed via the Click
>> file system. Write handlers called by, for example, Script elements
>> are not subject to the same constraints. (Maybe this should be
>> changed?...)
>>
>> Eddie
>>
>>
>> Roman Chertov wrote:
>>> Hello,
>>> I am making an element which will vary link properties based on a
>>> provided scenario file. A user app will periodically communicate
>>> with the Click module via the read/write handlers. Is it possible
>>> for run_task to execute while a write handler is executing? This can
>>> potentially corrupt the data structure which houses the link events.
>>> So I am curious if I need to add synchronization or not.
>>>
>>> Thanks,
>>>
>>> Roman
>>> _______________________________________________
>>> click mailing list
>>> click at amsterdam.lcs.mit.edu
>>> https://amsterdam.lcs.mit.edu/mailman/listinfo/click
>>
>
More information about the click
mailing list