source: rtems/tools/schedsim/shell/shared/main_taskcreate.c @ abff6d2

4.115
Last change on this file since abff6d2 was abff6d2, checked in by Joel Sherrill <joel.sherrill@…>, on 12/17/10 at 14:49:40

2010-12-17 Joel Sherrill <joel.sherrill@…>

Jennifer Averett <jennifer.averett@…>

Add RTEMS Scheduler Simulator. This is the shell scripting portion.

  • .cvsignore, ChangeLog?, Makefile.am, schedsim_priority/.cvsignore, schedsim_priority/Makefile.am, schedsim_priority/config.c, schedsim_priority/printheir_executing.c, schedsim_priority/schedsim.cc, schedsim_priority/wrap_thread_dispatch.c, scripts/script01, scripts/script02, scripts/script03, scripts/script04, scripts/script05, scripts/script06, shared/.cvsignore, shared/Makefile.am, shared/commands.c, shared/getopt.c, shared/lookup_semaphore.c, shared/lookup_task.c, shared/main_clocktick.c, shared/main_echo.c, shared/main_executing.c, shared/main_heir.c, shared/main_help.c, shared/main_rtemsinit.c, shared/main_semcreate.c, shared/main_semdelete.c, shared/main_semflush.c, shared/main_semobtain.c, shared/main_semrelease.c, shared/main_taskcreate.c, shared/main_taskdelete.c, shared/main_taskmode.c, shared/main_taskpriority.c, shared/main_taskresume.c, shared/main_tasksuspend.c, shared/main_taskwakeafter.c, shared/schedsim_shell.h, shared/shell_cmdset.c, shared/shell_makeargs.c, shared/include/shell.h, shared/include/newlib/_ansi.h, shared/include/newlib/getopt.h: New files.
  • Property mode set to 100644
File size: 2.2 KB
Line 
1/*
2 *  Task Create Shell Command Implmentation
3 *
4 *  COPYRIGHT (c) 1989-2010.
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 *  $Id$
12 */
13
14#ifdef HAVE_CONFIG_H
15#include "config.h"
16#endif
17
18#include <stdio.h>
19
20#include <rtems.h>
21#include "shell.h"
22#include <rtems/stringto.h>
23#include <schedsim_shell.h>
24#include <rtems/error.h>
25
26rtems_task dummy_task(
27  rtems_task_argument arg
28)
29{
30}
31
32int rtems_shell_main_task_create(
33  int   argc,
34  char *argv[]
35)
36{
37  char               name[5];
38  rtems_id           id;
39  rtems_status_code  status;
40  long               priority;
41 
42  if (argc != 3) {
43    fprintf( stderr, "%s: Usage name priority\n", argv[0] );
44    return -1;
45  }
46
47  if ( rtems_string_to_long(argv[2], &priority, NULL, 0) ) {
48    printf( "Seconds argument (%s) is not a number\n", argv[1] );
49    return -1;
50  }
51
52  /*
53   *  Now create the task
54   */
55  memset( name, '\0', sizeof(name) );
56  strncpy( name, argv[1], 4 );
57
58  status = rtems_task_create(
59    rtems_build_name( name[0], name[1], name[2], name[3] ),
60    (rtems_task_priority) priority,
61    RTEMS_MINIMUM_STACK_SIZE,
62    RTEMS_DEFAULT_MODES,
63    RTEMS_DEFAULT_ATTRIBUTES,
64    &id
65  );
66  if ( status ) {
67    fprintf(
68      stderr,
69      "Task Create(%s) returned %s\n",
70      argv[1],
71      rtems_status_text( status )
72    );
73    return -1;
74  }
75
76  printf(
77    "Task (%s) created: id=0x%08x, priority=%ld\n",
78    argv[1],
79    id,
80    priority
81  );
82 
83  printf(
84    "Task (%s) starting: id=0x%08x, priority=%ld\n",
85    argv[1],
86    id,
87    priority
88  );
89
90  status = rtems_task_start( id, dummy_task, 1 );
91  if ( status ) {
92    fprintf(
93      stderr,
94      "Task Start(%s) returned %s\n",
95      argv[1],
96      rtems_status_text( status )
97    );
98    return -1;
99  }
100
101  return 0;
102}
103
104rtems_shell_cmd_t rtems_shell_TASK_CREATE_Command = {
105  "task_create",                 /* name */
106  "task_create name priority",   /* usage */
107  "rtems",                       /* topic */
108  rtems_shell_main_task_create,  /* command */
109  NULL,                          /* alias */
110  NULL                           /* next */
111};
Note: See TracBrowser for help on using the repository browser.