summaryrefslogtreecommitdiff
path: root/cesar/mac/ca
diff options
context:
space:
mode:
authorschodet2009-10-02 16:03:04 +0000
committerschodet2009-10-02 16:03:04 +0000
commit80aeec75a3516cc1a119bccf56032078da05fb22 (patch)
treea1f85ec5f5a930202f465cc49b8013d5406a974d /cesar/mac/ca
parent95625afb8bf4fffcf6231b0b17d26a335b7a97a3 (diff)
* mac/ca (re #577):
- more isr protection. git-svn-id: svn+ssh://pessac/svn/cesar/trunk@5891 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/mac/ca')
-rw-r--r--cesar/mac/ca/src/ca.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/cesar/mac/ca/src/ca.c b/cesar/mac/ca/src/ca.c
index 7ca252f6f1..acc87f61bc 100644
--- a/cesar/mac/ca/src/ca.c
+++ b/cesar/mac/ca/src/ca.c
@@ -90,23 +90,23 @@ ca_mfs_remove (ca_t *ctx, mfs_tx_t *mfs)
dbg_assert (ctx);
dbg_assert (mfs);
CA_TRACE (MFS_REMOVE, mfs);
+ /* Lock. */
+ arch_isr_lock ();
/* Remove the MFS. */
switch (mfs->ca_state)
{
case CA_MFS_STATE_PRIO_QUEUED:
- arch_isr_lock ();
heap_remove (&ctx->mfs_heap, &mfs->ca_prio_link);
- arch_isr_unlock ();
break;
case CA_MFS_STATE_HELD:
- arch_isr_lock ();
list_remove (&ctx->held, &mfs->ca_held_link);
- arch_isr_unlock ();
break;
default:
;
}
mfs->ca_state = CA_MFS_STATE_REMOVED;
+ /* Unlock. */
+ arch_isr_unlock ();
/* The current ACCESS may have changed. */
ca_access_update (ctx, phy_date (ctx->phy));
}
@@ -119,6 +119,8 @@ ca_mfs_update_common (ca_t *ctx, mfs_tx_t *mfs, bool locked)
dbg_assert_ptr (mfs);
dbg_assert (mfs->ca_state != CA_MFS_STATE_REMOVED);
CA_TRACE (MFS_UPDATE, mfs);
+ /* Lock. */
+ if (!locked) arch_isr_lock ();
/* Ignore held MFS. */
if (mfs->ca_state == CA_MFS_STATE_HELD)
return;
@@ -135,21 +137,19 @@ ca_mfs_update_common (ca_t *ctx, mfs_tx_t *mfs, bool locked)
/* ...and execute the corresponding transition. */
if (mfs->ca_state == CA_MFS_STATE_PRIO_QUEUED)
{
- if (!locked) arch_isr_lock ();
if (new_state == CA_MFS_STATE_PRIO_QUEUED)
heap_adjust (&ctx->mfs_heap, &mfs->ca_prio_link);
else
heap_remove (&ctx->mfs_heap, &mfs->ca_prio_link);
- if (!locked) arch_isr_unlock ();
}
else if (new_state == CA_MFS_STATE_PRIO_QUEUED)
{
- if (!locked) arch_isr_lock ();
heap_insert (&ctx->mfs_heap, &mfs->ca_prio_link);
- if (!locked) arch_isr_unlock ();
}
/* Done. */
mfs->ca_state = new_state;
+ /* Unlock. */
+ if (!locked) arch_isr_unlock ();
/* The current ACCESS may have changed. */
if (!locked)
ca_access_update (ctx, phy_date (ctx->phy));
@@ -174,25 +174,28 @@ ca_mfs_hold_common (ca_t *ctx, mfs_tx_t *mfs, bool locked)
dbg_assert_ptr (mfs);
dbg_assert (mfs->ca_state != CA_MFS_STATE_REMOVED);
CA_TRACE (MFS_HOLD, mfs);
+ /* Lock. */
+ if (!locked) arch_isr_lock ();
/* Do nothing if held yet. */
if (mfs->ca_state != CA_MFS_STATE_HELD)
{
/* Remove from priority queue. */
if (mfs->ca_state == CA_MFS_STATE_PRIO_QUEUED)
- {
- if (!locked) arch_isr_lock ();
heap_remove (&ctx->mfs_heap, &mfs->ca_prio_link);
- if (!locked) arch_isr_unlock ();
- }
/* Add to hold list. */
- if (!locked) arch_isr_lock ();
mfs->ca_state = CA_MFS_STATE_HELD;
list_push (&ctx->held, &mfs->ca_held_link);
+ /* Unlock. */
if (!locked) arch_isr_unlock ();
/* The current ACCESS may have changed. */
if (!locked)
ca_access_update (ctx, phy_date (ctx->phy));
}
+ else
+ {
+ /* Unlock. */
+ if (!locked) arch_isr_unlock ();
+ }
}
void