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

Last change on this file since d23e0f0 was d23e0f0, checked in by Joel Sherrill <joel.sherrill@…>, on May 14, 2014 at 2:23:46 PM

main_taskpriority.c: Fix typo

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