source: rtems/cpukit/score/src/coremutex.c @ 1ff9922

4.104.114.95
Last change on this file since 1ff9922 was 1ff9922, checked in by Chris Johns <chrisj@…>, on 12/22/07 at 08:27:18

2007-12-22 Chris Johns <chrisj@…>

  • configure.ac: fixed bug that always enabled strict order mutexes.
  • score/inline/rtems/score/coremutex.inl: Fixed coding standard.
  • score/src/coremutex.c: Add the holder's thread to the lock_mutex list if the mutex is initialised locked.
  • libnetworking/rtems/rtems_glue.c: Changed semaphore error message to show the error is an rtems-net error.
  • libmisc/monitor/mon-network.c: Removed warnings.
  • telnetd/icmds.c: Changed shell_* to rtems_shell_*.
  • score/Makefile.am: Fixed typo that stopped 'make tags' working.
  • libmisc/shell/err.c, libmisc/shell/err.h, libmisc/shell/errx.c, libmisc/shell/extern-cp.h, libmisc/shell/fts.c, libmisc/shell/fts.h, libmisc/shell/main_cp.c, libmisc/shell/utils-cp.c, libmisc/shell/verr.c, libmisc/shell/verrx.c, libmisc/shell/vwarn.c, libmisc/shell/vwarnx.c, libmisc/shell/warn.c, libmisc/shell/warnx.c: New. Ported from BSD.
  • libmisc/shell/shellconfig.h: Add the cp command.
  • libmisc/Makefile.am: Add the new files to the shell.
  • libmisc/shell/shell.c, libmisc/shell/shell.h: Add scripting support.
  • libblock/src/flashdisk.c: Fixed disk drive count size setting bug.
  • Property mode set to 100644
File size: 2.5 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 *  $Id$
17 */
18
19#if HAVE_CONFIG_H
20#include "config.h"
21#endif
22
23#include <rtems/system.h>
24#include <rtems/score/isr.h>
25#include <rtems/score/coremutex.h>
26#include <rtems/score/states.h>
27#include <rtems/score/thread.h>
28#include <rtems/score/threadq.h>
29
30/*PAGE
31 *
32 *  _CORE_mutex_Initialize
33 *
34 *  This routine initializes a mutex at create time and set the control
35 *  structure according to the values passed.
36 *
37 *  Input parameters:
38 *    the_mutex             - the mutex control block to initialize
39 *    the_mutex_attributes  - the mutex attributes specified at create time
40 *    initial_lock          - mutex initial lock or unlocked status
41 *
42 *  Output parameters:  NONE
43 */
44
45void _CORE_mutex_Initialize(
46  CORE_mutex_Control           *the_mutex,
47  CORE_mutex_Attributes        *the_mutex_attributes,
48  uint32_t                      initial_lock
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  the_mutex->blocked_count = 0;
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    if ( _CORE_mutex_Is_inherit_priority( &the_mutex->Attributes ) ||
66         _CORE_mutex_Is_priority_ceiling( &the_mutex->Attributes ) )
67     
68#ifdef __STRICT_ORDER_MUTEX__
69       _Chain_Prepend_unprotected( &executing->lock_mutex,
70                                   &the_mutex->queue.lock_queue );
71       the_mutex->queue.priority_before = executing->current_priority;
72#endif
73
74      _Thread_Executing->resource_count++;
75  } else {
76    the_mutex->nest_count = 0;
77    the_mutex->holder     = NULL;
78    the_mutex->holder_id  = 0;
79  }
80
81  _Thread_queue_Initialize(
82    &the_mutex->Wait_queue,
83    _CORE_mutex_Is_fifo( the_mutex_attributes ) ?
84      THREAD_QUEUE_DISCIPLINE_FIFO : THREAD_QUEUE_DISCIPLINE_PRIORITY,
85    STATES_WAITING_FOR_MUTEX,
86    CORE_MUTEX_TIMEOUT
87  );
88}
Note: See TracBrowser for help on using the repository browser.