Ignore:
Timestamp:
Aug 12, 2015, 5:58:15 PM (9 years ago)
Author:
guerin
Message:

shell: add sleep command, misc fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/applications/shell/main.c

    r687 r703  
    88
    99#include "stdio.h"
    10 #include "string.h"
     10#include "stdlib.h"
    1111#include "malloc.h"
    1212
     
    243243    if ( ret == -2 )
    244244    {
    245         giet_tty_printf("\n  error : %s cannot be killed\n", argv[0] );
     245        giet_tty_printf("\n  error : %s cannot be killed\n", argv[1] );
    246246    }
    247247}
     
    251251{
    252252    giet_tasks_status();
     253}
     254
     255///////////////////////////////////////////////
     256static void cmd_sleep(int argc, char** argv)
     257{
     258    int start = giet_proctime();
     259
     260    if (argc < 2)
     261    {
     262        giet_tty_printf("%s <cycles>\n", argv[0]);
     263        return;
     264    }
     265
     266    while (giet_proctime() < start + atoi(argv[1]));
    253267}
    254268
     
    267281    { "kill",       cmd_kill },
    268282    { "ps",         cmd_ps },
     283    { "sleep",      cmd_sleep },
    269284    { NULL,         NULL }
    270285};
     
    273288
    274289///////////////////////////////////////
    275 static void parse(char *buf, int count)
     290static void parse(char *buf)
    276291{
    277292    int argc = 0;
     
    336351    // get a private TTY
    337352    giet_tty_alloc( 0 );
     353    giet_tty_printf( "~~~ shell ~~~\n" );
    338354
    339355    // display first prompt
     
    358374            {
    359375                buf[count] = '\0';
    360                 parse((char*)&buf, count);
     376                parse((char*)&buf);
    361377            }
    362378            prompt();
Note: See TracChangeset for help on using the changeset viewer.