2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
5 Desc: Change the priority of a task.
9 /**************************************************************************
15 ChangeTaskPri <priority> [ PROCESS <process number> ]
18 PRI=PRIORITY/A/N,PROCESS/K/N
24 The ChangeTaskPri command is used to change the current run
25 priority of a Task. As AROS is a multitasking operating
26 system, you can determine which tasks receive more CPU time
27 by changing their priorities.
29 The value of |priority| can be from -128 to 127, however values
30 greater than 4 are not recommended as they can interfere with
31 vital system processes. Higher values will give tasks a higher
34 You can use the Status command to examine the list of Tasks that
35 are running and their process numbers.
39 1.SYS:> ChangeTaskPri 1 Process 1
41 Set the priority of the current process to 1.
43 1.SYS:> ChangeTaskPri 1
45 Also sets the priority of the current process to 1.
50 **************************************************************************/
52 #include <exec/types.h>
53 #include <exec/tasks.h>
54 #include <dos/dosextens.h>
55 #include <dos/rdargs.h>
56 #include <proto/exec.h>
57 #include <proto/dos.h>
58 #include <utility/tagitem.h>
60 #define ARG_TEMPLATE "PRI=PRIORITY/A/N,PROCESS/N"
65 const TEXT version
[] = "$VER: ChangeTaskPri 41.2 (13.9.2005)";
66 static const char exthelp
[] =
67 "ChangeTaskPri : Change the priority of a CLI task\n"
68 "\tPRI=PRIORITY/A/N New priority of task\n"
69 "\tPROCESS/K Optional process number of change\n";
71 int __nocommandline
= 1;
75 struct Process
*pr
= NULL
;
76 struct RDArgs
*rda
= NULL
, *rdargs
;
77 IPTR args
[TOTAL_ARGS
] = { 0, 0 };
80 rda
= AllocDosObject(DOS_RDARGS
, NULL
);
83 rda
->RDA_ExtHelp
= (STRPTR
)exthelp
;
85 rdargs
= ReadArgs(ARG_TEMPLATE
, (IPTR
*)args
, rda
);
89 if( args
[ARG_PROCESS
] != 0 ) {
90 // Printf("PROCESS = %ld\n", *(LONG *)args[ARG_PROCESS]);
91 pr
= FindCliProc(*(LONG
*)args
[ARG_PROCESS
]);
94 pr
= (struct Process
*)FindTask(NULL
);
95 // Printf("pr = 0x%08lx\n", pr);
98 LONG pri
= (LONG
)(*(IPTR
*)args
[ARG_PRI
]);
100 /* Check the bounds on the priority */
101 if(pri
< -128 || pri
> 127 )
102 error
= ERROR_OBJECT_TOO_LARGE
;
104 /* Set the priority */
105 SetTaskPri( (struct Task
*)pr
, pri
);
112 errStream
= Output();
114 pr
= (struct Process
*)FindTask(NULL
);
115 if( pr
->pr_CES
!= NULL
)
116 errStream
= pr
->pr_CES
;
118 FPuts(errStream
, "ChangeTaskPri: Process does not exist.\n");
123 } /* ReadArgs() ok */
126 FreeDosObject(DOS_RDARGS
, rda
);
127 } /* Got a RDArgs * */
130 if( error
!= -1 && error
!= 0 )
132 PrintFault(error
, "ChangeTaskPri");