source: rtems/cpukit/score/src/coremutex.c @ 22ce0881

4.104.114.95
Last change on this file since 22ce0881 was 3899a537, checked in by Chris Johns <chrisj@…>, on 07/29/08 at 02:21:15

2008-07-29 Chris Johns <chrisj@…>

  • libblock/Makefile.am: Removed src/show_bdbuf.c.
  • libblock/src/show_bdbuf.c: Removed.
  • libblock/include/rtems/bdbuf.h, cpukit/libblock/src/bdbuf.c: Rewritten the bdbuf code. Remove pre-emption disable, score access, fixed many bugs and increased performance.
  • libblock/include/rtems/blkdev.h: Added RTEMS_BLKDEV_CAPABILITIES block device request. Cleaned up comments. Added block and user fields to the sg buffer request. Move to rtems_* namespace.
  • libblock/include/rtems/diskdevs.h, cpukit/libblock/src/diskdevs.c: Move to rtems_* namespace. Add a capabilities field for drivers. Change rtems_disk_lookup to rtems_disk_obtain to match the release call. You do not lookup and release a disk, you obtain and release a disk.
  • libblock/include/rtems/ide_part_table.h, libblock/include/rtems/ramdisk.h, libblock/src/ide_part_table.c: Move to rtems_* namespace.
  • libblock/include/rtems/nvdisk.h: Formatting change.
  • libblock/src/blkdev.c: Move to rtems_* namespace. Change rtems_disk_lookup to rtems_disk_obtain
  • libblock/src/flashdisk.c: Move to rtems_* namespace. Use the new support for the block number in the scatter/grather request struct. This allows non-continuous buffer requests for those drivers that can support increasing performance.
  • libblock/src/nvdisk.c: Move to rtems_* namespace. Removed warnings. Added better error checking. Fixed some comments.
  • libblock/src/ramdisk.c: Move to rtems_* namespace. Added some trace functions to help debugging upper layers. Use the new support for the block number in the scatter/grather request struct. This allows non-continuous buffer requests for those drivers that can support increasing performance.
  • libfs/src/dosfs/fat.c, libfs/src/dosfs/fat.h: Use new chains API. Removed temporary hack and changed set_errno_and_return_minus_one to rtems_set_errno_and_return_minus_one. Move fat_buf_access from header and stopped it being inlined. Updated to libblock changes.
  • libfs/src/dosfs/fat_fat_operations.c, libfs/src/dosfs/fat_file.c, libfs/src/dosfs/msdos_create.c, libfs/src/dosfs/msdos_dir.c, libfs/src/dosfs/msdos_eval.c, libfs/src/dosfs/msdos_file.c, libfs/src/dosfs/msdos_format.c, libfs/src/dosfs/msdos_free.c, libfs/src/dosfs/msdos_initsupp.c, libfs/src/dosfs/msdos_misc.c, libfs/src/dosfs/msdos_mknod.c: Use new chains API. Removed temporary hack and changed set_errno_and_return_minus_one to rtems_set_errno_and_return_minus_one. Updated to libblock changes.
  • libmisc/Makefile.am: Add new ls and rm command files.
  • libmisc/shell/cmp-ls.c, libmisc/shell/extern-ls.h, libmisc/shell/filemode.c, libmisc/shell/print-ls.c, libmisc/shell/pwcache.c, libmisc/shell/utils-ls.c, libmisc/shell/vis.c, shell/vis.h: New.
  • libmisc/shell/extern-cp.h, libmisc/shell/main_cp.c, libmisc/shell/utils-cp.c: Fixed the usage call bug.
  • libmisc/shell/main_blksync.c: Updated to the new block IO ioctl command.
  • libmisc/shell/main_ls.c, libmisc/shell/main_rm.c: Updated to BSD commands with more features.
  • score/src/coremutex.c: Fix the strick order mutex code.
  • libmisc/shell/shell.c: Change shell tasks mode to be timeslice and no ASR.
  • sapi/include/confdefs.h: Change ata_driver_task_priority to rtems_ata_driver_task_priority. Add the new BD buf cache parameters with defaults.
  • score/src/interr.c: Do not return if the CPU halt call returns.
  • 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 __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  } 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.