Advertisement
Guest User

Untitled

a guest
Sep 15th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #ifdef HAVE_CONFIG_H
  2. #include "config.h"
  3. #endif
  4.  
  5. #include <sys/param.h>
  6.  
  7. #include <stdio.h>
  8. #include <inttypes.h>
  9.  
  10. #include <rtems.h>
  11. #include <rtems/libcsupport.h>
  12. #include <rtems/score/schedulersmpimpl.h>
  13. #include <rtems/score/smpbarrier.h>
  14. #include <rtems/score/smplock.h>
  15.  
  16. #include "tmacros.h"
  17.  
  18. const char rtems_test_name[] = "SMPPESTI 8";
  19.  
  20. #define CPU_COUNT 3
  21.  
  22. #define MRSP_COUNT 4
  23.  
  24. static int flag;
  25.  
  26. typedef struct
  27. {
  28.     rtems_id main_task_id;
  29.     rtems_id scheduler_ids[CPU_COUNT];
  30.     rtems_id mrsp_id;
  31.     rtems_id task_id[3];
  32. } test_context;
  33.  
  34. static test_context test_instance;
  35.  
  36. static void Init(rtems_task_argument arg)
  37. {
  38.     TEST_BEGIN();
  39.     test_context *ctx = &test_instance;
  40.     uint32_t cpu_count = rtems_get_processor_count();
  41.  
  42.     rtems_status_code sc = rtems_semaphore_create(
  43.         rtems_build_name('M', 'R', 'S', 'P'),
  44.         1,
  45.         RTEMS_MULTIPROCESSOR_RESOURCE_SHARING | RTEMS_BINARY_SEMAPHORE,
  46.         9,
  47.         &ctx->mrsp_id);
  48.     rtems_test_assert(sc == RTEMS_SUCCESSFUL);
  49.  
  50.     printf("TASKS PRIORITY = 4\n");
  51.     printf("RESOURCE PRIORITY = 9\n");
  52.  
  53.     printf("OBTAINING THE RESOURCE\n");
  54.     sc = rtems_semaphore_obtain(ctx->mrsp_id, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
  55.     printf("EXPECTED RESULT = 19 (INVALID PRIORITY).\nOBTAINED = %d\n", sc);
  56.     rtems_test_assert(sc == 19);
  57.  
  58.     TEST_END();
  59.     rtems_test_exit(0);
  60. }
  61.  
  62. #define CONFIGURE_MICROSECONDS_PER_TICK 1000
  63.  
  64. #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
  65. #define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
  66.  
  67. #define CONFIGURE_MAXIMUM_TASKS 1
  68. #define CONFIGURE_MAXIMUM_SEMAPHORES 1
  69. #define CONFIGURE_MAXIMUM_MRSP_SEMAPHORES 1
  70.  
  71. #define CONFIGURE_MAXIMUM_PROCESSORS CPU_COUNT
  72.  
  73. #define CONFIGURE_INIT_TASK_NAME rtems_build_name('M', 'A', 'I', 'N')
  74. #define CONFIGURE_INIT_TASK_PRIORITY 4
  75.  
  76. #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
  77.  
  78. #define CONFIGURE_INIT
  79.  
  80. #include <rtems/confdefs.h>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement