Opened 16 years ago

Closed 16 years ago

Last modified 15 years ago

#508 closed Enhancement (fixed)

Recursive critical sections

Reported by: Nicolas Owned by: Bruce Allen
Priority: Trivial Milestone: Undetermined
Component: BOINC - API Version:
Keywords: patch Cc:

Description

If an application uses critical sections recursively, or uses a critical section during a checkpoint, the first boinc_end_critical_section call ends the critical section "prematurely". It would be better to change in_critical_section to be an int instead of a bool to keep the recursion count, and consider it shouldn't suspend if in_critical_section > 0

I'm attaching a patch that does this, to lower the work needed in case you actually think my enhancement suggestion is a good idea :) I changed !in_critical_section to >0. This is technically not needed since (!foo) == (foo!=0), but I think it's cleaner to have the comparison explicit.

(of course, feel free to resolve as wontfix if you disagree on the usefulness of the change)

Attachments (3)

recursive-critical-sections.diff (2.6 KB) - added by Nicolas 16 years ago.
Patch
recursive-critical-sections2.diff (2.5 KB) - added by Nicolas 16 years ago.
Modified patch, abstracting crit. sections from checkpoint code.
recursive-critical-sections3.diff (2.5 KB) - added by Nicolas 16 years ago.
Fixed stupid mistake (inverted conditions)

Download all attachments as: .zip

Change History (6)

Changed 16 years ago by Nicolas

Patch

Changed 16 years ago by Nicolas

Modified patch, abstracting crit. sections from checkpoint code.

comment:1 Changed 16 years ago by Nicolas

Wait, that's totally wrong. !in_critical_section should be replaced with in_critical_section == 0, not in_critical_section > 0!

Changed 16 years ago by Nicolas

Fixed stupid mistake (inverted conditions)

comment:2 Changed 16 years ago by Nicolas

Keywords: patch added

comment:3 Changed 16 years ago by davea

Resolution: fixed
Status: newclosed

(In [14694]) - API: critical section begin/end calls can be nested

Fixes #508 (from Nicolas)

Note: See TracTickets for help on using tickets.