source: rtems-schedsim/schedsim/shell/shared/main_taskpriority.c @ a2aad55

Last change on this file since a2aad55 was a2aad55, checked in by Joel Sherrill <joel.sherrill@…>, on 05/01/13 at 00:41:56

Remove CVS $

  • Property mode set to 100644
File size: 1.8 KB
Line 
1/*
2 *  Task Delete Shell Command Implmentation
3 *
4 *  COPYRIGHT (c) 1989-2013.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 */
11
12#ifdef HAVE_CONFIG_H
13#include "config.h"
14#endif
15
16#include <stdio.h>
17
18#include <rtems.h>
19#include "shell.h"
20#include <rtems/stringto.h>
21#include <schedsim_shell.h>
22#include <rtems/error.h>
23
24int rtems_shell_main_task_priority(
25  int   argc,
26  char *argv[]
27)
28{
29  rtems_id             id;
30  rtems_status_code    status;
31  unsigned long        tmp;
32  rtems_task_priority  old;
33  rtems_task_priority  new;
34 
35  CHECK_RTEMS_IS_UP();
36
37  if (argc != 3) {
38    fprintf( stderr, "%s: Usage [name|id] priority\n", argv[0] );
39    return -1;
40  }
41
42  if ( lookup_task( argv[1], &id ) )
43    return -1;
44
45  if ( rtems_string_to_unsigned_long( argv[2], &tmp, NULL, 0) ) {
46    fprintf( stderr, "Argument (%s) is not a number\n", argv[2] );
47    return 1;
48  }
49
50  new = (rtems_task_priority) tmp;
51
52  /*
53   *  Now priority the task
54   */
55  status = rtems_task_set_priority( id, new, &old );
56  if ( status != RTEMS_SUCCESSFUL ) {
57    fprintf(
58      stderr,
59      "Task Set Priority(%s) returned %s\n",
60      argv[1],
61      rtems_status_text( status )
62    );
63    return -1;
64  }
65
66  if ( new != 0 )
67    printf("Task (0x%08x) Change Priority from %d to %d\n", id, old, new );
68  else
69    printf("Task (0x%08x) Current Priority is %d\n", id, new );
70 
71  return 0;
72}
73
74rtems_shell_cmd_t rtems_shell_TASK_PRIORITY_Command = {
75  "task_priority",                 /* name */
76  "task_priority name priority",   /* usage */
77  "rtems",                         /* topic */
78  rtems_shell_main_task_priority,  /* command */
79  NULL,                            /* alias */
80  NULL                             /* next */
81};
Note: See TracBrowser for help on using the repository browser.