source:
rtems/tools/schedsim/shell/shared/main_taskcreate.c
@
abff6d2
Last change on this file since abff6d2 was abff6d2, checked in by Joel Sherrill <joel.sherrill@…>, on 12/17/10 at 14:49:40 | |
---|---|
|
|
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 | |
26 | rtems_task dummy_task( |
27 | rtems_task_argument arg |
28 | ) |
29 | { |
30 | } |
31 | |
32 | int 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 | |
104 | rtems_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.