Possible problem with CONFIGURE_MAXIMUM_SEMAPHORES succeeding

Joel Sherrill joel.sherrill at OARcorp.com
Thu Feb 10 21:18:50 UTC 2011


On 02/10/2011 03:15 PM, Andrei Chichak wrote:
> Hi all,
>
> I was adding another semaphore to my code and decided to test the 
> semaphore create failure case first. I added the create without 
> incrementing the maximum number of semaphores that was configured. The 
> create succeeded rather than failed.
>
> I created 4 semaphores with the maximum set to 3. All returned 
> rtems_status_code == 0. I set the maximum to 2, same. I set the 
> maximum to 1, same. I set the maximum to 0, same result.
>
> This is running on an Axiom CML5282 using RTEMS 4.9.4 and a BSP that 
> is heavily based on the AV5282 and UC5282 BSPs.
>
> Any ideas?
>
Yep.  Many of the configuration parameters are "human friendly"
and imply the configuration of more basic objects.

#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 20


/**
  *  From the number of file descriptors, we can determine how many
  *  semaphores the implementation will require.
  */
#define CONFIGURE_LIBIO_SEMAPHORES \
   (CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS + 1)

You need a mutex per open file plus one for the management
of the collection.
>
> I started stripping out code until my program generates this:
>
>
> create sem1 semaphore returned with 0
>
> create sem2 semaphore returned with 0
>
> create sem3 semaphore returned with 0
>
> create sem4 semaphore returned with 0
>
>
> From this (only comments have been removed):
>
>
> #include<rtems.h>
>
> rtems_task Init(rtems_task_argument ignored);
>
> #include<bsp.h>
>
> #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
> #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
> #define CONFIGURE_MAXIMUM_TASKS1
> #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES0
>
> #define CONFIGURE_MAXIMUM_SEMAPHORES0
>
> #define CONFIGURE_MAXIMUM_TIMERS0
> #define CONFIGURE_MAXIMUM_PARTITIONS0
> #define CONFIGURE_MAXIMUM_DRIVERS20
>
> #define STACK_CHECKER_ON
>
> #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 20
>
> #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
> #define CONFIGURE_INIT
>
> #include<rtems/confdefs.h>
>
> static rtems_id sem1;
> static rtems_id sem2;
> static rtems_id sem3;
> static rtems_id sem4;
>
> rtems_task Init(rtems_task_argument ignored) {
>
> rtems_status_code status;
>
> status = rtems_semaphore_create( rtems_build_name('S','E','M','1'),
> 1,
> RTEMS_PRIORITY | RTEMS_BINARY_SEMAPHORE | RTEMS_INHERIT_PRIORITY | 
> RTEMS_NO_PRIORITY_CEILING | RTEMS_LOCAL,
> 0,
> &sem1);
>
> printk("create sem1 semaphore returned with %d\n", status);
>
> status = rtems_semaphore_create( rtems_build_name('S','E','M','2'),
> 1,
> RTEMS_PRIORITY | RTEMS_BINARY_SEMAPHORE | RTEMS_INHERIT_PRIORITY | 
> RTEMS_NO_PRIORITY_CEILING | RTEMS_LOCAL,
> 0,
> &sem2);
>
> printk("create sem2 semaphore returned with %d\n", status);
>
> status = rtems_semaphore_create( rtems_build_name('S','E','M','3'),
> 1,
> RTEMS_PRIORITY | RTEMS_BINARY_SEMAPHORE | RTEMS_INHERIT_PRIORITY | 
> RTEMS_NO_PRIORITY_CEILING | RTEMS_LOCAL,
> 0,
> &sem3);
>
> printk("create sem3 semaphore returned with %d\n", status);
>
> status = rtems_semaphore_create( rtems_build_name('S','E','M','4'),
> 1,
> RTEMS_PRIORITY | RTEMS_BINARY_SEMAPHORE | RTEMS_INHERIT_PRIORITY | 
> RTEMS_NO_PRIORITY_CEILING | RTEMS_LOCAL,
> 0,
> &sem4);
>
> printk("create sem4 semaphore returned with %d\n", status);
>
> status = rtems_task_delete( RTEMS_SELF);
> exit(0);
> }
>
>
>


-- 
Joel Sherrill, Ph.D.             Director of Research&  Development
joel.sherrill at OARcorp.com        On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
    Support Available             (256) 722-9985





More information about the users mailing list