mirror of https://github.com/zrafa/xinu-avr.git
29 changed files with 245 additions and 67 deletions
@ -0,0 +1,16 @@
|
||||
|
||||
#include <xinu.h> |
||||
|
||||
void change_proc_name( char *name) |
||||
{ |
||||
struct procent *prptr; /* pointer to proc. table entry */ |
||||
int i; |
||||
|
||||
|
||||
prptr = &proctab[currpid]; |
||||
|
||||
prptr->prname[PNMLEN-1] = NULLCH; |
||||
for (i=0 ; i<PNMLEN-1 && (prptr->prname[i]=name[i])!=NULLCH; i++) |
||||
; |
||||
} |
||||
|
||||
@ -0,0 +1,17 @@
|
||||
/* xsh_forever.c - xsh_forever */ |
||||
|
||||
#include <xinu.h> |
||||
#include <stdio.h> |
||||
|
||||
/*------------------------------------------------------------------------
|
||||
* xsh_forever |
||||
*------------------------------------------------------------------------ |
||||
*/ |
||||
shellcmd xsh_forever(int nargs, char *args[]) |
||||
{ |
||||
|
||||
for (;;) |
||||
printf("a"); |
||||
|
||||
return 0; |
||||
} |
||||
@ -0,0 +1,47 @@
|
||||
/* xsh_kill.c - xsh_kill */ |
||||
|
||||
#include <xinu.h> |
||||
#include <string.h> |
||||
#include <stdio.h> |
||||
|
||||
/*------------------------------------------------------------------------
|
||||
* xsh_kill - obtain and print the current month, day, year, and time |
||||
*------------------------------------------------------------------------ |
||||
*/ |
||||
shellcmd xsh_kill(int nargs, char *args[]) { |
||||
|
||||
int32 retval; /* return value */ |
||||
pid32 pid; /* ID of process to kill */ |
||||
char ch; /* next character of argument */ |
||||
char *chptr; /* walks along argument string */ |
||||
|
||||
/* Check argument count */ |
||||
|
||||
if (nargs != 2) { |
||||
return SYSERR; |
||||
} |
||||
|
||||
/* compute process ID from argument string */ |
||||
|
||||
chptr = args[1]; |
||||
ch = *chptr++; |
||||
pid = 0; |
||||
while(ch != NULLCH) { |
||||
if ( (ch < '0') || (ch > '9') ) { |
||||
return 1; |
||||
} |
||||
pid = 10*pid + (ch - '0'); |
||||
ch = *chptr++; |
||||
} |
||||
if (pid == 0) { |
||||
return 1; |
||||
} |
||||
|
||||
retval = kill(pid); |
||||
if (retval == SYSERR) { |
||||
//fprintf(stderr, "%s: cannot kill process %d\n",
|
||||
// args[0], pid);
|
||||
return 1; |
||||
} |
||||
return 0; |
||||
} |
||||
@ -0,0 +1,47 @@
|
||||
/* xsh_uptime.c - xsh_uptime */ |
||||
#include <xinu.h> |
||||
#include <stdio.h> |
||||
#include <string.h> |
||||
|
||||
/*------------------------------------------------------------------------
|
||||
* xsh_uptime - shell to print the time the system has been up |
||||
*------------------------------------------------------------------------ |
||||
*/ |
||||
shellcmd xsh_uptime(int nargs, char *args[]) |
||||
{ |
||||
long days, hrs, mins, secs; /* days, hours, minutes, and */ |
||||
/* seconds since system boot */ |
||||
long secperday = 86400; /* seconds in a day */ |
||||
long secperhr = 3600; /* seconds in an hour */ |
||||
long secpermin = 60; /* seconds in a minute */
|
||||
|
||||
/* Check for valid number of arguments */ |
||||
|
||||
if (nargs > 1) { |
||||
return 1; |
||||
} |
||||
|
||||
secs = clktime; /* total seconds since boot */ |
||||
|
||||
/* subtract number of whole days */ |
||||
|
||||
days = secs/secperday; |
||||
secs -= days*secperday; |
||||
|
||||
/* subtract number of hours */ |
||||
|
||||
hrs = secs/secperhr; |
||||
secs -= hrs*secperhr; |
||||
|
||||
/* subtract number of minutes */ |
||||
|
||||
mins = secs/secpermin; |
||||
secs -= mins*secpermin; |
||||
|
||||
printf(" %d day(s) &", days); |
||||
printf(" %dh:", hrs); |
||||
printf("%dm:", mins); |
||||
printf("%ds\n", secs); |
||||
|
||||
return 0; |
||||
} |
||||
Loading…
Reference in new issue