OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems/] [c/] [src/] [exec/] [score/] [src/] [coremutex.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 158 chris
/*
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.OARcorp.com/rtems/license.html.
15
 *
16 208 chris
 *  $Id: coremutex.c,v 1.2 2001-09-27 11:59:34 chris Exp $
17 158 chris
 */
18
 
19
#include <rtems/system.h>
20
#include <rtems/score/isr.h>
21
#include <rtems/score/coremutex.h>
22
#include <rtems/score/states.h>
23
#include <rtems/score/thread.h>
24
#include <rtems/score/threadq.h>
25
 
26
/*PAGE
27
 *
28
 *  _CORE_mutex_Initialize
29
 *
30
 *  This routine initializes a mutex at create time and set the control
31
 *  structure according to the values passed.
32
 *
33
 *  Input parameters:
34
 *    the_mutex             - the mutex control block to initialize
35
 *    the_class             - the API class of the object
36
 *    the_mutex_attributes  - the mutex attributes specified at create time
37
 *    initial_lock          - mutex initial lock or unlocked status
38
 *    proxy_extract_callout - MP specific extract callout
39
 *
40
 *  Output parameters:  NONE
41
 */
42
 
43
void _CORE_mutex_Initialize(
44
  CORE_mutex_Control           *the_mutex,
45
  Objects_Classes               the_class,
46
  CORE_mutex_Attributes        *the_mutex_attributes,
47
  unsigned32                    initial_lock,
48
  Thread_queue_Extract_callout  proxy_extract_callout
49
)
50
{
51
 
52
/* Add this to the RTEMS environment later ?????????
53
  rtems_assert( initial_lock == CORE_MUTEX_LOCKED ||
54
                initial_lock == CORE_MUTEX_UNLOCKED );
55
 */
56
 
57
  the_mutex->Attributes = *the_mutex_attributes;
58
  the_mutex->lock       = initial_lock;
59
 
60
#if 0
61
  if ( !the_mutex_attributes->only_owner_release &&
62
       the_mutex_attributes->nesting_allowed ) {
63
    _Internal_error_Occurred(
64
      INTERNAL_ERROR_CORE,
65
      TRUE,
66
      INTERNAL_ERROR_BAD_ATTRIBUTES
67
    );
68
  }
69
#endif
70
 
71
  if ( initial_lock == CORE_MUTEX_LOCKED ) {
72
    the_mutex->nest_count = 1;
73
    the_mutex->holder     = _Thread_Executing;
74
    the_mutex->holder_id  = _Thread_Executing->Object.id;
75
    _Thread_Executing->resource_count++;
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
    the_class,
85
    _CORE_mutex_Is_fifo( the_mutex_attributes ) ?
86
      THREAD_QUEUE_DISCIPLINE_FIFO : THREAD_QUEUE_DISCIPLINE_PRIORITY,
87
    STATES_WAITING_FOR_MUTEX,
88
    proxy_extract_callout,
89
    CORE_MUTEX_TIMEOUT
90
  );
91
}
92
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.