source: rtems/cpukit/score/src/coremutex.c @ 62181b21

4.115
Last change on this file since 62181b21 was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 15:09:24

Remove All CVS Id Strings Possible Using a Script

Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines

next to each other after Id string line removed.

+ remove entire comment blocks which only exited to

contain CVS Ids

+ If the processing left a blank line at the top of

a file, it was removed.

  • Property mode set to 100644
File size: 2.7 KB
Line 
1/*
2 *  Mutex Handler
3 *
4 *  DESCRIPTION:
5 *
6 *  This package is the implementation of the Mutex Handler.
7 *  This handler provides synchronization and mutual exclusion capabilities.
8 *
9 *  COPYRIGHT (c) 1989-1999.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.com/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/system.h>
22#include <rtems/score/isr.h>
23#include <rtems/score/coremutex.h>
24#include <rtems/score/states.h>
25#include <rtems/score/thread.h>
26#include <rtems/score/threadq.h>
27
28/*
29 *  _CORE_mutex_Initialize
30 *
31 *  This routine initializes a mutex at create time and set the control
32 *  structure according to the values passed.
33 *
34 *  Input parameters:
35 *    the_mutex             - the mutex control block to initialize
36 *    the_mutex_attributes  - the mutex attributes specified at create time
37 *    initial_lock          - mutex initial lock or unlocked status
38 *
39 *  Output parameters:  NONE
40 */
41
42CORE_mutex_Status _CORE_mutex_Initialize(
43  CORE_mutex_Control           *the_mutex,
44  CORE_mutex_Attributes        *the_mutex_attributes,
45  uint32_t                      initial_lock
46)
47{
48
49/* Add this to the RTEMS environment later ?????????
50  rtems_assert( initial_lock == CORE_MUTEX_LOCKED ||
51                initial_lock == CORE_MUTEX_UNLOCKED );
52 */
53
54  the_mutex->Attributes    = *the_mutex_attributes;
55  the_mutex->lock          = initial_lock;
56  the_mutex->blocked_count = 0;
57
58  if ( initial_lock == CORE_MUTEX_LOCKED ) {
59    the_mutex->nest_count = 1;
60    the_mutex->holder     = _Thread_Executing;
61    the_mutex->holder_id  = _Thread_Executing->Object.id;
62    if ( _CORE_mutex_Is_inherit_priority( &the_mutex->Attributes ) ||
63         _CORE_mutex_Is_priority_ceiling( &the_mutex->Attributes ) ) {
64
65      if ( _Thread_Executing->current_priority <
66             the_mutex->Attributes.priority_ceiling )
67       return CORE_MUTEX_STATUS_CEILING_VIOLATED;
68#ifdef __RTEMS_STRICT_ORDER_MUTEX__
69       _Chain_Prepend_unprotected( &_Thread_Executing->lock_mutex,
70                                   &the_mutex->queue.lock_queue );
71       the_mutex->queue.priority_before = _Thread_Executing->current_priority;
72#endif
73
74      _Thread_Executing->resource_count++;
75    }
76  } else {
77    the_mutex->nest_count = 0;
78    the_mutex->holder     = NULL;
79    the_mutex->holder_id  = 0;
80  }
81
82  _Thread_queue_Initialize(
83    &the_mutex->Wait_queue,
84    _CORE_mutex_Is_fifo( the_mutex_attributes ) ?
85      THREAD_QUEUE_DISCIPLINE_FIFO : THREAD_QUEUE_DISCIPLINE_PRIORITY,
86    STATES_WAITING_FOR_MUTEX,
87    CORE_MUTEX_TIMEOUT
88  );
89
90  return CORE_MUTEX_STATUS_SUCCESSFUL;
91}
Note: See TracBrowser for help on using the repository browser.