Changeset 5a4bb75 in rtems


Ignore:
Timestamp:
Apr 26, 2012, 12:28:52 PM (8 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
6b36ca23
Parents:
27272db3
git-author:
Sebastian Huber <sebastian.huber@…> (04/26/12 12:28:52)
git-committer:
Sebastian Huber <sebastian.huber@…> (05/04/12 08:53:51)
Message:

Filesystem: Remove per file descriptor semaphore

The per file descriptor semaphore (field of rtems_libio_t) is unused in
RTEMS. There is a considerable memory overhead due to that. A
semaphore needs roughly 124 bytes which is huge compared to the
approximately 72 bytes for the file descriptor structure itself. Device
drivers can create their own synchronization primitives in the open
handler on demand.

Files:
13 edited

Legend:

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

    r27272db3 r5a4bb75  
    11661166  uint32_t                                flags;
    11671167  rtems_filesystem_location_info_t        pathinfo;
    1168   rtems_id                                sem;
    11691168  uint32_t                                data0;     /* private to "driver" */
    11701169  void                                   *data1;     /* ... */
  • cpukit/libcsupport/src/libio.c

    r27272db3 r5a4bb75  
    132132rtems_libio_t *rtems_libio_allocate( void )
    133133{
    134   rtems_libio_t *iop, *next;
    135   rtems_status_code rc;
    136   rtems_id sema;
     134  rtems_libio_t *iop = NULL;
    137135
    138136  rtems_libio_lock();
    139137
    140138  if (rtems_libio_iop_freelist) {
    141     rc = rtems_semaphore_create(
    142       RTEMS_LIBIO_IOP_SEM(rtems_libio_iop_freelist - rtems_libio_iops),
    143       1,
    144       RTEMS_BINARY_SEMAPHORE | RTEMS_INHERIT_PRIORITY | RTEMS_PRIORITY,
    145       0,
    146       &sema
    147     );
    148     if (rc != RTEMS_SUCCESSFUL)
    149       goto failed;
    150139    iop = rtems_libio_iop_freelist;
    151     next = iop->data1;
    152     (void) memset( iop, 0, sizeof(rtems_libio_t) );
     140    rtems_libio_iop_freelist = iop->data1;
     141    memset( iop, 0, sizeof(*iop) );
    153142    iop->flags = LIBIO_FLAGS_OPEN;
    154     iop->sem = sema;
    155     rtems_libio_iop_freelist = next;
    156     goto done;
    157143  }
    158144
    159 failed:
    160   iop = 0;
     145  rtems_libio_unlock();
    161146
    162 done:
    163   rtems_libio_unlock();
    164147  return iop;
    165148}
     
    180163  rtems_libio_lock();
    181164
    182     if (iop->sem)
    183       rtems_semaphore_delete(iop->sem);
    184 
    185165    iop->flags &= ~LIBIO_FLAGS_OPEN;
    186166    iop->data1 = rtems_libio_iop_freelist;
  • cpukit/sapi/include/confdefs.h

    r27272db3 r5a4bb75  
    120120
    121121/**
    122  *  From the number of file descriptors, we can determine how many
    123  *  semaphores the implementation will require.
    124  */
    125 #define CONFIGURE_LIBIO_SEMAPHORES \
    126   (CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS + 1)
     122 *  Semaphore count used by the IO library.
     123 */
     124#define CONFIGURE_LIBIO_SEMAPHORES 1
    127125
    128126#ifdef CONFIGURE_INIT
  • testsuites/sptests/spfatal14/Makefile.am

    r27272db3 r5a4bb75  
    1212
    1313AM_CPPFLAGS += -I$(top_srcdir)/../support/include
    14 AM_CPPFLAGS += -DSEMAPHORES_REMAINING=5
    1514
    1615LINK_OBJS = $(spfatal14_OBJECTS)
  • testsuites/sptests/spfatal14/testcase.h

    r27272db3 r5a4bb75  
    1818#define FATAL_ERROR_EXPECTED_ERROR       0x55544431
    1919
    20 #define CONFIGURE_APPLICATION_PREREQUISITE_DRIVERS \
    21   CONSUME_SEMAPHORE_DRIVERS
     20#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 1
    2221
    2322void force_error()
  • testsuites/sptests/spfatal15/Makefile.am

    r27272db3 r5a4bb75  
    1212
    1313AM_CPPFLAGS += -I$(top_srcdir)/../support/include
    14 AM_CPPFLAGS += -DSEMAPHORES_REMAINING=6
    1514
    1615LINK_OBJS = $(spfatal15_OBJECTS)
  • testsuites/sptests/spfatal15/testcase.h

    r27272db3 r5a4bb75  
    1717#define FATAL_ERROR_EXPECTED_ERROR       0x55544432
    1818
    19 #define CONFIGURE_APPLICATION_PREREQUISITE_DRIVERS \
    20   { consume_semaphores_initialize, NULL, NULL, NULL, NULL, NULL }
     19#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 2
    2120
    2221void force_error()
  • testsuites/sptests/spfatal16/testcase.h

    r27272db3 r5a4bb75  
    2525void force_error()
    2626{
    27   /* we will not run this far */
     27  /* This fatal error depends on the Termios device configuration */
     28  printk( "*** END OF TEST FATAL " FATAL_ERROR_TEST_NAME " ***\n" );
     29  rtems_test_exit(0);
    2830}
  • testsuites/sptests/spfatal17/Makefile.am

    r27272db3 r5a4bb75  
    1212
    1313AM_CPPFLAGS += -I$(top_srcdir)/../support/include
    14 AM_CPPFLAGS += -DSEMAPHORES_REMAINING=4
     14AM_CPPFLAGS += -DSEMAPHORES_REMAINING=3
    1515
    1616LINK_OBJS = $(spfatal17_OBJECTS)
  • testsuites/sptests/spfatal18/Makefile.am

    r27272db3 r5a4bb75  
    1212
    1313AM_CPPFLAGS += -I$(top_srcdir)/../support/include
    14 AM_CPPFLAGS += -DSEMAPHORES_REMAINING=3
     14AM_CPPFLAGS += -DSEMAPHORES_REMAINING=2
    1515
    1616LINK_OBJS = $(spfatal18_OBJECTS)
  • testsuites/sptests/spfatal19/Makefile.am

    r27272db3 r5a4bb75  
    1212
    1313AM_CPPFLAGS += -I$(top_srcdir)/../support/include
    14 AM_CPPFLAGS += -DSEMAPHORES_REMAINING=2
     14AM_CPPFLAGS += -DSEMAPHORES_REMAINING=1
    1515
    1616LINK_OBJS = $(spfatal19_OBJECTS)
  • testsuites/sptests/spfatal20/testcase.h

    r27272db3 r5a4bb75  
    88 *
    99 *  $Id$
    10  */
    11 
    12 /* generate fatal errors in termios.c
    13  *    rtems_semaphore_create( rtems_build_name ('T', 'R', 'r', c),...);
    1410 */
    1511
  • testsuites/sptests/spfifo02/init.c

    r27272db3 r5a4bb75  
    146146  puts( "Creating FIFO" );
    147147  create_fifo();
    148  
    149   puts( "Opening FIFO.. expect ENFILE (semaphore @ open could not be created)" );
    150   open_fifo(ENFILE, O_RDWR);
    151 
    152   delete_semaphore();
     148
    153149  puts( "Opening FIFO.. expect ENOMEM (semaphore for pipe could not be created)" );
    154150  open_fifo(ENOMEM, O_RDWR);
Note: See TracChangeset for help on using the changeset viewer.