Subversion Repositories shark

Rev

Blame | Last modification | View Log | RSS feed

/*
 * Project: HARTIK (HA-rd R-eal TI-me K-ernel)
 *
 * Coordinators: Giorgio Buttazzo <giorgio@sssup.it>
 *               Gerardo Lamastra <gerardo@sssup.it>
 *
 * Authors     : Paolo Gai <pj@hartik.sssup.it>
 * (see authors.txt for full list of hartik's authors)
 *
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
 *
 * http://www.sssup.it
 * http://retis.sssup.it
 * http://hartik.sssup.it
 */


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

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

 Test Number 15 (F):

 This test verify the correctness of the PI module.


 the main task (NRT) lock a PI mutex.
 then 2 tasks arrives, with priority higher than the main

 the first try to lock the mutex, but it can't, so the main inherit
 his priority. The second simply prints a string.

 If all works, the string of the second task is printed after the end of
 the first task.

**/


/*
 * 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 "kernel/kern.h"

mutex_t        m1;


TASK pippo1(void *a)
{
//  int i=0;
//  struct timespec t;
//  int last = 0;

  kern_printf("pippo1 prima di mutex_lock\n");
  mutex_lock(&m1);
  kern_printf("pippo1 dopo mutex_lock\n");

  mutex_unlock(&m1);
  kern_printf("pippo1 dopo mutex_unlock\n");
  return 0;
}

TASK pippo2()
{
 kern_printf("pippo2 Dentro pippo2\n");
 return 0;
}

int main(int argc, char **argv)
{
//  struct timespec t;
//  int i;
  HARD_TASK_MODEL m;
  PID p2,p3;

  PI_mutexattr_t a;

  hard_task_default_model(m);
  hard_task_def_mit(m,50000);
  hard_task_def_wcet(m,10000);
  hard_task_def_group(m,1);

  hard_task_def_arg(m,(void *)1);
  p2 = task_create("pippo1", pippo1, &m, NULL);
  if (p2 == NIL)
  { kern_printf("Can't create pippo1 task...\n"); return 1; }

  hard_task_def_mit(m,100000);
  p3 = task_create("pippo2", pippo2, &m, NULL);
  if (p3 == NIL)
  { kern_printf("Can't create pippo2 task...\n"); return 1; }

  PI_mutexattr_default(a);
  mutex_init(&m1,&a);

  kern_printf("main prima di mutex_lock\n");
  mutex_lock(&m1);
  kern_printf("main dopo mutex_lock, exec=%d, exec_shadow=%d\n", exec, exec_shadow);

  group_activate(1);

  kern_printf("main dopo group_activate, exec=%d, exec_shadow=%d\n", exec, exec_shadow);
  mutex_unlock(&m1);
  kern_printf("main dopo mutex_unlock\n");

  mutex_destroy(&m1);
  kern_printf("main dopo mutex_destroy\n");

  return 0;
}