Changeset 2ca0a7b in rtems


Ignore:
Timestamp:
Apr 11, 2014, 1:41:27 PM (5 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
589bbcb
Parents:
53e008b
git-author:
Sebastian Huber <sebastian.huber@…> (04/11/14 13:41:27)
git-committer:
Sebastian Huber <sebastian.huber@…> (04/14/14 06:37:04)
Message:

capture: Use ISR lock for SMP support

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libmisc/capture/capture.c

    r53e008b r2ca0a7b  
    8686static rtems_task_priority      capture_floor;
    8787static rtems_id                 capture_reader;
     88static rtems_interrupt_lock     capture_lock =
     89  RTEMS_INTERRUPT_LOCK_INITIALIZER("capture");
    8890
    8991/*
     
    336338rtems_capture_create_control (rtems_name name, rtems_id id)
    337339{
    338   rtems_interrupt_level    level;
    339   rtems_capture_control_t* control;
    340   rtems_capture_task_t*    task;
     340  rtems_interrupt_lock_context lock_context;
     341  rtems_capture_control_t*     control;
     342  rtems_capture_task_t*        task;
    341343
    342344  if ((name == 0) && (id == 0))
     
    364366    memset (control->by, 0, sizeof (control->by));
    365367
    366     rtems_interrupt_disable (level);
     368    rtems_interrupt_lock_acquire (&capture_lock, &lock_context);
    367369
    368370    control->next    = capture_controls;
     
    377379        task->control = control;
    378380
    379     rtems_interrupt_enable (level);
     381    rtems_interrupt_lock_release (&capture_lock, &lock_context);
    380382  }
    381383
     
    394396rtems_capture_create_capture_task (rtems_tcb* new_task)
    395397{
    396   rtems_interrupt_level    level;
    397   rtems_capture_task_t*    task;
    398   rtems_capture_control_t* control;
    399   rtems_name               name;
    400   rtems_capture_time_t     time;
    401   bool                     ok;
     398  rtems_interrupt_lock_context lock_context;
     399  rtems_capture_task_t*        task;
     400  rtems_capture_control_t*     control;
     401  rtems_name                   name;
     402  rtems_capture_time_t         time;
     403  bool                         ok;
    402404
    403405  ok = rtems_workspace_allocate (sizeof (*task), (void **) &task);
     
    441443  task->stack_clean    = task->stack_size;
    442444
    443   rtems_interrupt_disable (level);
     445  rtems_interrupt_lock_acquire (&capture_lock, &lock_context);
    444446
    445447  task->forw    = capture_tasks;
     
    449451  capture_tasks = task;
    450452
    451   rtems_interrupt_enable (level);
     453  rtems_interrupt_lock_release (&capture_lock, &lock_context);
    452454
    453455  /*
     
    479481  if (task)
    480482  {
    481     rtems_interrupt_level level;
    482 
    483     rtems_interrupt_disable (level);
     483    rtems_interrupt_lock_context lock_context;
     484
     485    rtems_interrupt_lock_acquire (&capture_lock, &lock_context);
    484486
    485487    if (task->tcb || task->refcount)
     
    496498    }
    497499
    498     rtems_interrupt_enable (level);
     500    rtems_interrupt_lock_release (&capture_lock, &lock_context);
    499501
    500502    rtems_workspace_free (task);
     
    539541          (control && (control->flags & RTEMS_CAPTURE_WATCH)))))
    540542    {
    541       rtems_interrupt_level level;
    542 
    543       rtems_interrupt_disable (level);
     543      rtems_interrupt_lock_context lock_context;
     544
     545      rtems_interrupt_lock_acquire (&capture_lock, &lock_context);
    544546
    545547      if (capture_count < capture_size)
     
    565567      else
    566568        capture_flags |= RTEMS_CAPTURE_OVERFLOW;
    567       rtems_interrupt_enable (level);
     569      rtems_interrupt_lock_release (&capture_lock, &lock_context);
    568570    }
    569571  }
     
    10511053rtems_capture_close (void)
    10521054{
    1053   rtems_interrupt_level    level;
    1054   rtems_capture_task_t*    task;
    1055   rtems_capture_control_t* control;
    1056   rtems_status_code        sc;
    1057 
    1058   rtems_interrupt_disable (level);
     1055  rtems_interrupt_lock_context lock_context;
     1056  rtems_capture_task_t*        task;
     1057  rtems_capture_control_t*     control;
     1058  rtems_status_code            sc;
     1059
     1060  rtems_interrupt_lock_acquire (&capture_lock, &lock_context);
    10591061
    10601062  if (!capture_records)
    10611063  {
    1062     rtems_interrupt_enable (level);
     1064    rtems_interrupt_lock_release (&capture_lock, &lock_context);
    10631065    return RTEMS_SUCCESSFUL;
    10641066  }
     
    10681070  capture_records = NULL;
    10691071
    1070   rtems_interrupt_enable (level);
     1072  rtems_interrupt_lock_release (&capture_lock, &lock_context);
    10711073
    10721074  /*
     
    11271129rtems_capture_control (bool enable)
    11281130{
    1129   rtems_interrupt_level level;
    1130 
    1131   rtems_interrupt_disable (level);
     1131  rtems_interrupt_lock_context lock_context;
     1132
     1133  rtems_interrupt_lock_acquire (&capture_lock, &lock_context);
    11321134
    11331135  if (!capture_records)
    11341136  {
    1135     rtems_interrupt_enable (level);
     1137    rtems_interrupt_lock_release (&capture_lock, &lock_context);
    11361138    return RTEMS_UNSATISFIED;
    11371139  }
     
    11441146  rtems_iterate_over_all_threads (rtems_capture_task_setup);
    11451147
    1146   rtems_interrupt_enable (level);
     1148  rtems_interrupt_lock_release (&capture_lock, &lock_context);
    11471149
    11481150  return RTEMS_SUCCESSFUL;
     
    11611163rtems_capture_monitor (bool enable)
    11621164{
    1163   rtems_interrupt_level level;
    1164 
    1165   rtems_interrupt_disable (level);
     1165  rtems_interrupt_lock_context lock_context;
     1166
     1167  rtems_interrupt_lock_acquire (&capture_lock, &lock_context);
    11661168
    11671169  if (!capture_records)
    11681170  {
    1169     rtems_interrupt_enable (level);
     1171    rtems_interrupt_lock_release (&capture_lock, &lock_context);
    11701172    return RTEMS_UNSATISFIED;
    11711173  }
     
    11761178    capture_flags &= ~RTEMS_CAPTURE_ONLY_MONITOR;
    11771179
    1178   rtems_interrupt_enable (level);
     1180  rtems_interrupt_lock_release (&capture_lock, &lock_context);
    11791181
    11801182  return RTEMS_SUCCESSFUL;
     
    11921194rtems_capture_flush (bool prime)
    11931195{
    1194   rtems_interrupt_level level;
    1195   rtems_capture_task_t* task;
    1196 
    1197   rtems_interrupt_disable (level);
     1196  rtems_interrupt_lock_context lock_context;
     1197  rtems_capture_task_t*        task;
     1198
     1199  rtems_interrupt_lock_acquire (&capture_lock, &lock_context);
    11981200
    11991201  for (task = capture_tasks; task != NULL; task = task->forw)
     
    12121214  capture_out   = 0;
    12131215
    1214   rtems_interrupt_enable (level);
     1216  rtems_interrupt_lock_release (&capture_lock, &lock_context);
    12151217
    12161218  task = capture_tasks;
     
    12701272rtems_capture_watch_del (rtems_name name, rtems_id id)
    12711273{
    1272   rtems_interrupt_level     level;
    1273   rtems_capture_control_t*  control;
    1274   rtems_capture_control_t** prev_control;
    1275   rtems_capture_task_t*     task;
    1276   bool                      found = false;
     1274  rtems_interrupt_lock_context lock_context;
     1275  rtems_capture_control_t*     control;
     1276  rtems_capture_control_t**    prev_control;
     1277  rtems_capture_task_t*        task;
     1278  bool                         found = false;
    12771279
    12781280  /*
     
    12851287    if (rtems_capture_match_name_id (control->name, control->id, name, id))
    12861288    {
    1287       rtems_interrupt_disable (level);
     1289      rtems_interrupt_lock_acquire (&capture_lock, &lock_context);
    12881290
    12891291      for (task = capture_tasks; task != NULL; task = task->forw)
     
    12931295      *prev_control = control->next;
    12941296
    1295       rtems_interrupt_enable (level);
     1297      rtems_interrupt_lock_release (&capture_lock, &lock_context);
    12961298
    12971299      rtems_workspace_free (control);
     
    13251327rtems_capture_watch_ctrl (rtems_name name, rtems_id id, bool enable)
    13261328{
    1327   rtems_interrupt_level    level;
    1328   rtems_capture_control_t* control;
    1329   bool                     found = false;
     1329  rtems_interrupt_lock_context lock_context;
     1330  rtems_capture_control_t*     control;
     1331  bool                         found = false;
    13301332
    13311333  /*
     
    13371339    if (rtems_capture_match_name_id (control->name, control->id, name, id))
    13381340    {
    1339       rtems_interrupt_disable (level);
     1341      rtems_interrupt_lock_acquire (&capture_lock, &lock_context);
    13401342
    13411343      if (enable)
     
    13441346        control->flags &= ~RTEMS_CAPTURE_WATCH;
    13451347
    1346       rtems_interrupt_enable (level);
     1348      rtems_interrupt_lock_release (&capture_lock, &lock_context);
    13471349
    13481350      found = true;
     
    13681370rtems_capture_watch_global (bool enable)
    13691371{
    1370   rtems_interrupt_level level;
    1371 
    1372   rtems_interrupt_disable (level);
     1372  rtems_interrupt_lock_context lock_context;
     1373
     1374  rtems_interrupt_lock_acquire (&capture_lock, &lock_context);
    13731375
    13741376  /*
     
    13811383    capture_flags &= ~RTEMS_CAPTURE_GLOBAL_WATCH;
    13821384
    1383   rtems_interrupt_enable (level);
     1385  rtems_interrupt_lock_release (&capture_lock, &lock_context);
    13841386
    13851387  return RTEMS_SUCCESSFUL;
     
    16961698                    rtems_capture_record_t** recs)
    16971699{
    1698   rtems_interrupt_level level;
    1699   rtems_status_code     sc = RTEMS_SUCCESSFUL;
    1700   uint32_t              count;
     1700  rtems_interrupt_lock_context lock_context;
     1701  rtems_status_code            sc = RTEMS_SUCCESSFUL;
     1702  uint32_t                     count;
    17011703
    17021704  *read = 0;
    17031705  *recs = NULL;
    17041706
    1705   rtems_interrupt_disable (level);
     1707  rtems_interrupt_lock_acquire (&capture_lock, &lock_context);
    17061708
    17071709  /*
     
    17111713  if (capture_flags & RTEMS_CAPTURE_READER_ACTIVE)
    17121714  {
    1713     rtems_interrupt_enable (level);
     1715    rtems_interrupt_lock_release (&capture_lock, &lock_context);
    17141716    return RTEMS_RESOURCE_IN_USE;
    17151717  }
     
    17181720  *read = count = capture_count;
    17191721
    1720   rtems_interrupt_enable (level);
     1722  rtems_interrupt_lock_release (&capture_lock, &lock_context);
    17211723
    17221724  *recs = &capture_records[capture_out];
     
    17451747        rtems_task_ident (RTEMS_SELF, RTEMS_LOCAL, &capture_reader);
    17461748
    1747         rtems_interrupt_disable (level);
     1749        rtems_interrupt_lock_acquire (&capture_lock, &lock_context);
    17481750
    17491751        capture_flags |= RTEMS_CAPTURE_READER_WAITING;
    17501752
    1751         rtems_interrupt_enable (level);
     1753        rtems_interrupt_lock_release (&capture_lock, &lock_context);
    17521754
    17531755        sc = rtems_event_receive (RTEMS_EVENT_0,
     
    17641766          break;
    17651767
    1766         rtems_interrupt_disable (level);
     1768        rtems_interrupt_lock_acquire (&capture_lock, &lock_context);
    17671769
    17681770        *read = count = capture_count;
    17691771
    1770         rtems_interrupt_enable (level);
     1772        rtems_interrupt_lock_release (&capture_lock, &lock_context);
    17711773
    17721774        continue;
     
    17941796rtems_capture_release (uint32_t count)
    17951797{
    1796   rtems_capture_record_t* rec;
    1797   uint32_t                counted;
    1798 
    1799   rtems_interrupt_level level;
    1800 
    1801   rtems_interrupt_disable (level);
     1798  rtems_interrupt_lock_context lock_context;
     1799  rtems_capture_record_t*      rec;
     1800  uint32_t                     counted;
     1801
     1802  rtems_interrupt_lock_acquire (&capture_lock, &lock_context);
    18021803
    18031804  if (count > capture_count)
    18041805    count = capture_count;
    18051806
    1806   rtems_interrupt_enable (level);
     1807  rtems_interrupt_lock_release (&capture_lock, &lock_context);
    18071808
    18081809  counted = count;
     
    18171818  }
    18181819
    1819   rtems_interrupt_disable (level);
     1820  rtems_interrupt_lock_acquire (&capture_lock, &lock_context);
    18201821
    18211822  capture_count -= count;
     
    18251826  capture_flags &= ~RTEMS_CAPTURE_READER_ACTIVE;
    18261827
    1827   rtems_interrupt_enable (level);
     1828  rtems_interrupt_lock_release (&capture_lock, &lock_context);
    18281829
    18291830  return RTEMS_SUCCESSFUL;
Note: See TracChangeset for help on using the changeset viewer.