Changeset 3200227 in rtems-schedsim
- Timestamp:
- 05/16/14 19:46:36 (10 years ago)
- Branches:
- master
- Children:
- 9f3c8eb
- Parents:
- 08abc0f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
schedsim/shell/shared/main_taskcreate.c
r08abc0f r3200227 14 14 #endif 15 15 16 #define _GNU_SOURCE 17 #include <sys/cpuset.h> 18 16 19 #include <stdio.h> 17 20 … … 49 52 ) 50 53 { 54 char *c_p; 51 55 char name[5]; 52 56 rtems_id id; … … 58 62 char option; 59 63 int arg; 64 unsigned long affinity; 65 cpu_set_t cpuset; 66 bool do_affinity; 60 67 61 68 CHECK_RTEMS_IS_UP(); … … 63 70 mode = 0; 64 71 mask = 0; 72 do_affinity = false; 65 73 memset(&getopt_reent, 0, sizeof(getopt_data)); 66 while ( (option = getopt_r( argc, argv, " tTpP", &getopt_reent)) != -1 ) {74 while ( (option = getopt_r( argc, argv, "a:tTpP", &getopt_reent)) != -1 ) { 67 75 switch (option) { 76 case 'a': 77 c_p = getopt_reent.optarg; 78 if ( rtems_string_to_unsigned_long( c_p, &affinity, NULL, 0) ) { 79 fprintf( stderr, "Affinity (%s) is not a number\n", argv[2] ); 80 return 1; 81 } 82 do_affinity = true; 83 84 CPU_ZERO( &cpuset ); 85 cpuset.__bits[0] = affinity; 86 break; 87 68 88 case 't': 69 89 mask |= RTEMS_TIMESLICE_MASK; … … 94 114 */ 95 115 arg = getopt_reent.optind; 96 if ( (argc - arg) != 2){97 fprintf( stderr, "%s: Usage [args] name priority \n", argv[0] );116 if ( ((argc - arg) != 2) && ((argc - arg) != 4) ){ 117 fprintf( stderr, "%s: Usage [args] name priority -a affinity\n", argv[0] ); 98 118 return -1; 99 119 } 100 120 101 121 if ( rtems_string_to_long(argv[arg+1], &priority, NULL, 0) ) { 102 printf( " Secondsargument (%s) is not a number\n", argv[1] );122 printf( "Priority argument (%s) is not a number\n", argv[1] ); 103 123 return -1; 104 124 } … … 135 155 ); 136 156 157 /* 158 * If specified, set the affinity 159 */ 160 if ( do_affinity ) { 161 status = rtems_task_set_affinity( id, sizeof(cpuset), &cpuset ); 162 if ( status != RTEMS_SUCCESSFUL ) { 163 fprintf( 164 stderr, 165 "Task Set Affinity(0x%08x) returned %s\n" 166 "Deleting task 0x%08x\n", 167 affinity, 168 rtems_status_text( status ), 169 id 170 ); 171 rtems_task_delete( id ); 172 return -1; 173 } 174 printf("Task (0x%08x) Set affinity=0x%08x\n", id, cpuset.__bits[0] ); 175 } 176 177 /* 178 * Starting the task 179 */ 137 180 printf( 138 181 "Task (%s) starting: id=0x%08x, priority=%ld\n",
Note: See TracChangeset
for help on using the changeset viewer.