Subversion Repositories shark

Rev

Rev 1086 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

/*
 * Project: S.Ha.R.K.
 *
 * Coordinators:
 *   Giorgio Buttazzo    <giorgio@sssup.it>
 *   Paolo Gai           <pj@gandalf.sssup.it>
 *
 * Authors     :
 *   Paolo Gai           <pj@gandalf.sssup.it>
 *   (see the web pages for full authors list)
 *
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
 *
 * http://www.sssup.it
 * http://retis.sssup.it
 * http://shark.sssup.it
 */


/**
 ------------
 CVS :        $Id: ptest5.c,v 1.1.1.1 2002-09-02 09:37:47 pj Exp $

 File:        $File$
 Revision:    $Revision: 1.1.1.1 $
 Last update: $Date: 2002-09-02 09:37:47 $
 ------------

 Posix test 5:
   an alarm test

 non standard function used:
   cprintf
   sys_gettime
   keyboard stuffs
   sys_end

**/


/*
 * Copyright (C) 2000 Paolo Gai
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */


#include <sys/types.h>
#include <pthread.h>
#include <signal.h>
#include <unistd.h>

#include <kernel/kern.h>
#include <drivers/keyb.h>



void signal_handler(int signo, siginfo_t *info, void *extra)
{
  cprintf("SIGNAL HANDLER: pid=%d\n",exec_shadow);
}

void fine(KEY_EVT *e)
{
  sys_end();
}


int main(int argc, char **argv)
{
  struct sigaction sig_act;

    KEY_EVT emerg;
    //keyb_set_map(itaMap);
    emerg.ascii = 'x';
    emerg.scan = KEY_X;
    emerg.flag = ALTL_BIT;
    keyb_hook(emerg,fine);

  sig_act.sa_sigaction = (void *) signal_handler;
  sig_act.sa_flags = SA_SIGINFO;
  sigemptyset(&sig_act.sa_mask);

  sigaction(SIGALRM, &sig_act, NULL);

  cprintf("main: alarm(5), waiting t=2 sec\n");
  alarm(5);

  while (sys_gettime(NULL) < 2000000);

  cprintf("main: alarm(3) return %d, waiting t=6 sec\n",alarm(3));

  pause();
//  while (sys_gettime(NULL) < 6000000);

  cprintf("main: ending...\n");

  return 0;
}