Changeset ac74162 in rtems


Ignore:
Timestamp:
Sep 14, 2017, 1:21:14 PM (2 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
8fa75d3
Parents:
baef823c
git-author:
Sebastian Huber <sebastian.huber@…> (09/14/17 13:21:14)
git-committer:
Sebastian Huber <sebastian.huber@…> (09/15/17 08:55:38)
Message:

libio: Use FIFO for iop free list

Update #3136.

Files:
6 edited

Legend:

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

    rbaef823c rac74162  
    6767extern const uint32_t rtems_libio_number_iops;
    6868extern rtems_libio_t rtems_libio_iops[];
    69 extern rtems_libio_t *rtems_libio_iop_freelist;
     69extern void *rtems_libio_iop_free_head;
     70extern void **rtems_libio_iop_free_tail;
    7071
    7172extern const rtems_filesystem_file_handlers_r rtems_filesystem_null_handlers;
  • cpukit/libcsupport/src/libio.c

    rbaef823c rac74162  
    109109rtems_libio_t *rtems_libio_allocate( void )
    110110{
    111   rtems_libio_t *iop = NULL;
     111  rtems_libio_t *iop;
    112112
    113113  rtems_libio_lock();
    114114
    115   if (rtems_libio_iop_freelist) {
    116     iop = rtems_libio_iop_freelist;
    117     rtems_libio_iop_freelist = iop->data1;
    118     memset( iop, 0, sizeof(*iop) );
     115  iop = rtems_libio_iop_free_head;
     116
     117  if ( iop != NULL ) {
     118    void *next;
     119
     120    next = iop->data1;
     121    rtems_libio_iop_free_head = next;
     122
     123    if ( next == NULL ) {
     124      rtems_libio_iop_free_tail = &rtems_libio_iop_free_head;
     125    }
    119126  }
    120127
     
    132139  rtems_libio_lock();
    133140
    134     iop->flags = 0;
    135     iop->data1 = rtems_libio_iop_freelist;
    136     rtems_libio_iop_freelist = iop;
     141  iop = memset( iop, 0, sizeof( *iop ) );
     142  *rtems_libio_iop_free_tail = iop;
     143  rtems_libio_iop_free_tail = &iop->data1;
    137144
    138145  rtems_libio_unlock();
  • cpukit/libcsupport/src/libio_init.c

    rbaef823c rac74162  
    3939 */
    4040
    41 rtems_id           rtems_libio_semaphore;
    42 rtems_libio_t     *rtems_libio_iop_freelist;
     41rtems_id rtems_libio_semaphore;
     42
     43void *rtems_libio_iop_free_head;
     44
     45void **rtems_libio_iop_free_tail = &rtems_libio_iop_free_head;
    4346
    4447static void rtems_libio_init( void )
     
    5154    if (rtems_libio_number_iops > 0)
    5255    {
    53         iop = rtems_libio_iop_freelist = &rtems_libio_iops[0];
     56        iop = rtems_libio_iop_free_head = &rtems_libio_iops[0];
    5457        for (i = 0 ; (i + 1) < rtems_libio_number_iops ; i++, iop++)
    5558          iop->data1 = iop + 1;
    5659        iop->data1 = NULL;
     60        rtems_libio_iop_free_tail = &iop->data1;
    5761    }
    5862
  • cpukit/libcsupport/src/resource_snapshot.c

    rbaef823c rac74162  
    8888  rtems_libio_lock();
    8989
    90   iop = rtems_libio_iop_freelist;
     90  iop = rtems_libio_iop_free_head;
    9191  while (iop != NULL) {
    9292    ++free_count;
  • testsuites/fstests/fsclose01/init.c

    rbaef823c rac74162  
    406406}
    407407
     408static void test_fd_free_fifo(const char *path)
     409{
     410  int a;
     411  int b;
     412  int rv;
     413
     414  a = open(path, O_RDWR);
     415  rtems_test_assert(a >= 0);
     416
     417  rv = close(a);
     418  rtems_test_assert(rv == 0);
     419
     420  b = open(path, O_RDWR);
     421  rtems_test_assert(b >= 0);
     422
     423  rv = close(b);
     424  rtems_test_assert(rv == 0);
     425
     426  rtems_test_assert(a != b);
     427}
     428
    408429static void test(test_context *ctx)
    409430{
     
    420441  );
    421442  rtems_test_assert(rv == 0);
     443
     444  test_fd_free_fifo(path);
    422445
    423446  sc = rtems_task_create(
     
    470493  rtems_test_assert(rv == 0);
    471494
    472   rtems_test_assert(ctx->close_count == 15);
     495  rtems_test_assert(ctx->close_count == 17);
    473496  rtems_test_assert(ctx->fcntl_count == 1);
    474497  rtems_test_assert(ctx->fdatasync_count == 1);
    475   rtems_test_assert(ctx->fstat_count == 38);
     498  rtems_test_assert(ctx->fstat_count == 42);
    476499  rtems_test_assert(ctx->fsync_count == 1);
    477500  rtems_test_assert(ctx->ftruncate_count == 1);
    478501  rtems_test_assert(ctx->ioctl_count == 1);
    479502  rtems_test_assert(ctx->lseek_count == 1);
    480   rtems_test_assert(ctx->open_count == 15);
     503  rtems_test_assert(ctx->open_count == 17);
    481504  rtems_test_assert(ctx->read_count == 1);
    482505  rtems_test_assert(ctx->readv_count == 1);
     
    496519#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
    497520
    498 #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 4
     521#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 5
    499522
    500523#define CONFIGURE_MAXIMUM_TASKS 2
  • testsuites/libtests/termios01/init.c

    rbaef823c rac74162  
    624624  int fd;
    625625  int rv;
     626  int i;
    626627
    627628  rtems_resource_snapshot_take( &snapshot );
     
    630631  rtems_test_assert( sc == RTEMS_SUCCESSFUL );
    631632
    632   errno = 0;
    633   fd = open( &dev[0], O_RDWR );
    634   rtems_test_assert( fd == -1 );
    635   rtems_test_assert( errno == ENXIO );
     633  /*
     634   * The loop ensures that file descriptor 0 is the first free file descriptor
     635   * after this test case.
     636   */
     637  for (i = 0; i < 4; ++i) {
     638    errno = 0;
     639    fd = open( &dev[0], O_RDWR );
     640    rtems_test_assert( fd == -1 );
     641    rtems_test_assert( errno == ENXIO );
     642  }
    636643
    637644  rv = unlink( &dev[0] );
Note: See TracChangeset for help on using the changeset viewer.