source: rtems/c/src/exec/score/src/coremutex.c @ 82cb78d8

4.104.114.84.95
Last change on this file since 82cb78d8 was 82cb78d8, checked in by Joel Sherrill <joel.sherrill@…>, on 11/02/99 at 21:45:15

Split core message queue and watchdog handler objects into separate files.

  • Property mode set to 100644
File size: 2.3 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-1998.
10 *  On-Line Applications Research Corporation (OAR).
11 *  Copyright assigned to U.S. Government, 1994.
12 *
13 *  The license and distribution terms for this file may be
14 *  found in the file LICENSE in this distribution or at
15 *  http://www.OARcorp.com/rtems/license.html.
16 *
17 *  $Id$
18 */
19
20#include <rtems/system.h>
21#include <rtems/score/isr.h>
22#include <rtems/score/coremutex.h>
23#include <rtems/score/states.h>
24#include <rtems/score/thread.h>
25#include <rtems/score/threadq.h>
26
27/*PAGE
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_class             - the API class of the object
37 *    the_mutex_attributes  - the mutex attributes specified at create time
38 *    initial_lock          - mutex initial lock or unlocked status
39 *    proxy_extract_callout - MP specific extract callout
40 *
41 *  Output parameters:  NONE
42 */
43
44void _CORE_mutex_Initialize(
45  CORE_mutex_Control           *the_mutex,
46  Objects_Classes               the_class,
47  CORE_mutex_Attributes        *the_mutex_attributes,
48  unsigned32                    initial_lock,
49  Thread_queue_Extract_callout  proxy_extract_callout
50)
51{
52
53/* Add this to the RTEMS environment later ?????????
54  rtems_assert( initial_lock == CORE_MUTEX_LOCKED ||
55                initial_lock == CORE_MUTEX_UNLOCKED );
56 */
57
58  the_mutex->Attributes = *the_mutex_attributes;
59  the_mutex->lock          = initial_lock;
60
61  if ( initial_lock == CORE_MUTEX_LOCKED ) {
62    the_mutex->nest_count = 1;
63    the_mutex->holder     = _Thread_Executing;
64    the_mutex->holder_id  = _Thread_Executing->Object.id;
65    _Thread_Executing->resource_count++;
66  } else {
67    the_mutex->nest_count = 0;
68    the_mutex->holder     = NULL;
69    the_mutex->holder_id  = 0;
70  }
71
72  _Thread_queue_Initialize(
73    &the_mutex->Wait_queue,
74    the_class,
75    _CORE_mutex_Is_fifo( the_mutex_attributes ) ?
76      THREAD_QUEUE_DISCIPLINE_FIFO : THREAD_QUEUE_DISCIPLINE_PRIORITY,
77    STATES_WAITING_FOR_MUTEX,
78    proxy_extract_callout,
79    CORE_MUTEX_TIMEOUT
80  );
81}
82
Note: See TracBrowser for help on using the repository browser.