Changeset bc5b56a in rtems


Ignore:
Timestamp:
Dec 4, 2017, 7:56:00 AM (2 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
3b446741
Parents:
98b52e3
git-author:
Sebastian Huber <sebastian.huber@…> (12/04/17 07:56:00)
git-committer:
Sebastian Huber <sebastian.huber@…> (12/06/17 06:13:04)
Message:

libio: Use API mutex

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libcsupport/include/rtems/libio_.h

    r98b52e3 rbc5b56a  
    5252 */
    5353#define F_DUP2FD 20
    54 
    55 /*
    56  *  Semaphore to protect the io table
    57  */
    58 
    59 #define RTEMS_LIBIO_SEM         rtems_build_name('L', 'B', 'I', 'O')
    60 #define RTEMS_LIBIO_IOP_SEM(n)  rtems_build_name('L', 'B', 'I', n)
    61 
    62 extern rtems_id                          rtems_libio_semaphore;
    6354
    6455/*
     
    348339extern pthread_key_t rtems_current_user_env_key;
    349340
    350 static inline void rtems_libio_lock( void )
    351 {
    352   rtems_semaphore_obtain( rtems_libio_semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT );
    353 }
    354 
    355 static inline void rtems_libio_unlock( void )
    356 {
    357   rtems_semaphore_release( rtems_libio_semaphore );
    358 }
     341void rtems_libio_lock( void );
     342
     343void rtems_libio_unlock( void );
    359344
    360345static inline void rtems_filesystem_mt_lock( void )
  • cpukit/libcsupport/src/libio_init.c

    r98b52e3 rbc5b56a  
    1919#endif
    2020
    21 #include <rtems/libio_.h>               /* libio_.h pulls in rtems */
    22 #include <rtems.h>
    23 #include <rtems/assoc.h>                /* assoc.h not included by rtems.h */
     21#include <rtems/libio_.h>
    2422
    25 #include <stdio.h>                      /* O_RDONLY, et.al. */
    26 #include <fcntl.h>                      /* O_RDONLY, et.al. */
    27 #include <errno.h>
     23#include <pthread.h>
    2824
    29 #include <errno.h>
    30 #include <string.h>                     /* strcmp */
    31 #include <unistd.h>
    32 #include <stdlib.h>                     /* calloc() */
    33 
    34 #include <rtems/libio.h>                /* libio.h not pulled in by rtems */
    3525#include <rtems/sysinit.h>
     26#include <rtems/score/apimutex.h>
    3627
    3728/*
     
    3930 */
    4031
    41 rtems_id rtems_libio_semaphore;
     32static API_Mutex_Control rtems_libio_mutex = API_MUTEX_INITIALIZER( "_Libio" );
     33
     34void rtems_libio_lock( void )
     35{
     36  _API_Mutex_Lock( &rtems_libio_mutex );
     37}
     38
     39void rtems_libio_unlock( void )
     40{
     41  _API_Mutex_Unlock( &rtems_libio_mutex );
     42}
    4243
    4344void *rtems_libio_iop_free_head;
     
    4748static void rtems_libio_init( void )
    4849{
    49     rtems_status_code rc;
    5050    uint32_t i;
    5151    rtems_libio_t *iop;
     
    7171    _Internal_error( INTERNAL_ERROR_LIBIO_USER_ENV_KEY_CREATE_FAILED );
    7272  }
    73 
    74   /*
    75    *  Create the binary semaphore used to provide mutual exclusion
    76    *  on the IOP Table.
    77    */
    78 
    79   rc = rtems_semaphore_create(
    80     RTEMS_LIBIO_SEM,
    81     1,
    82     RTEMS_BINARY_SEMAPHORE | RTEMS_INHERIT_PRIORITY | RTEMS_PRIORITY,
    83     RTEMS_NO_PRIORITY,
    84     &rtems_libio_semaphore
    85   );
    86   if ( rc != RTEMS_SUCCESSFUL ) {
    87     _Internal_error( INTERNAL_ERROR_LIBIO_SEM_CREATE_FAILED );
    88   }
    8973}
    9074
  • cpukit/sapi/include/confdefs.h

    r98b52e3 rbc5b56a  
    140140  #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 3
    141141#endif
    142 
    143 /*
    144  * Semaphore count used by the IO library.
    145  */
    146 #define _CONFIGURE_LIBIO_SEMAPHORES 1
    147142
    148143/*
     
    21212116   */
    21222117  #define _CONFIGURE_SEMAPHORES \
    2123     (CONFIGURE_MAXIMUM_SEMAPHORES + _CONFIGURE_LIBIO_SEMAPHORES + \
     2118    (CONFIGURE_MAXIMUM_SEMAPHORES + \
    21242119      _CONFIGURE_TERMIOS_SEMAPHORES + _CONFIGURE_LIBBLOCK_SEMAPHORES + \
    21252120      _CONFIGURE_SEMAPHORES_FOR_FILE_SYSTEMS + \
  • cpukit/score/include/rtems/score/interr.h

    r98b52e3 rbc5b56a  
    183183  INTERNAL_ERROR_POSIX_INIT_THREAD_CREATE_FAILED = 33,
    184184  INTERNAL_ERROR_LIBIO_USER_ENV_KEY_CREATE_FAILED = 34,
    185   INTERNAL_ERROR_LIBIO_SEM_CREATE_FAILED = 35,
     185  /* INTERNAL_ERROR_LIBIO_SEM_CREATE_FAILED = 35, */
    186186  INTERNAL_ERROR_LIBIO_STDOUT_FD_OPEN_FAILED = 36,
    187187  INTERNAL_ERROR_LIBIO_STDERR_FD_OPEN_FAILED = 37,
  • testsuites/sptests/spsysinit01/init.c

    r98b52e3 rbc5b56a  
    517517FIRST(RTEMS_SYSINIT_LIBIO)
    518518{
    519   assert(rtems_libio_semaphore == 0);
     519  assert(rtems_libio_iop_free_head == NULL);
    520520  next_step(LIBIO_PRE);
    521521}
     
    523523LAST(RTEMS_SYSINIT_LIBIO)
    524524{
    525   assert(rtems_libio_semaphore != 0);
     525  assert(rtems_libio_iop_free_head == &rtems_libio_iops[0]);
    526526  next_step(LIBIO_POST);
    527527}
Note: See TracChangeset for help on using the changeset viewer.