OpenCores
URL https://opencores.org/ocsvn/plasma/plasma/trunk

Subversion Repositories plasma

[/] [plasma/] [trunk/] [kernel/] [rtos_test.c] - Diff between revs 402 and 407

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 402 Rev 407
Line 7... Line 7...
 * COPYRIGHT: Software placed into the public domain by the author.
 * COPYRIGHT: Software placed into the public domain by the author.
 *    Software 'as is' without warranty.  Author liable for nothing.
 *    Software 'as is' without warranty.  Author liable for nothing.
 * DESCRIPTION:
 * DESCRIPTION:
 *    Test Plasma Real Time Operating System
 *    Test Plasma Real Time Operating System
 *--------------------------------------------------------------------*/
 *--------------------------------------------------------------------*/
 
#ifdef WIN32
 
#include <stdlib.h>
 
#endif
#include "plasma.h"
#include "plasma.h"
#include "rtos.h"
#include "rtos.h"
#include "tcpip.h"
#include "tcpip.h"
 
 
/* Including mmu.h will cause all OS calls to use SYSCALL */
/* Including mmu.h will cause all OS calls to use SYSCALL */
Line 142... Line 145...
 
 
   thread = OS_ThreadSelf();
   thread = OS_ThreadSelf();
   priority = OS_ThreadPriorityGet(thread);
   priority = OS_ThreadPriorityGet(thread);
   OS_ThreadSleep(10);
   OS_ThreadSleep(10);
   printf("Arg=%d thread=0x%x info=0x%x priority=%d\n",
   printf("Arg=%d thread=0x%x info=0x%x priority=%d\n",
      (uint32)arg, thread, OS_ThreadInfoGet(thread, 0), priority);
      (int)arg, (int)thread, (int)OS_ThreadInfoGet(thread, 0), priority);
   OS_ThreadExit();
   OS_ThreadExit();
}
}
 
 
static void TestThread(void)
static void TestThread(void)
{
{
Line 243... Line 246...
   OS_MutexPost(info->MyMutex);
   OS_MutexPost(info->MyMutex);
 
 
   OS_ThreadExit();
   OS_ThreadExit();
}
}
 
 
 
//Test priority inversion
 
static void TestMutexThread2(void *arg)
 
{
 
   (void)arg;
 
   printf("Priority inversion test thread\n");
 
}
 
 
static void TestMutex(void)
static void TestMutex(void)
{
{
   TestInfo_t info;
   TestInfo_t info;
   printf("TestMutex\n");
   printf("TestMutex\n");
   info.MyMutex = OS_MutexCreate("MyMutex");
   info.MyMutex = OS_MutexCreate("MyMutex");
   OS_MutexPend(info.MyMutex);
   OS_MutexPend(info.MyMutex);
   OS_MutexPend(info.MyMutex);
   OS_MutexPend(info.MyMutex);
   OS_MutexPend(info.MyMutex);
   OS_MutexPend(info.MyMutex);
 
   printf("Acquired mutexes\n");
 
 
   OS_ThreadSleep(100);
   OS_ThreadCreate("TestMutex", TestMutexThread, &info, 150, 0);
 
   OS_ThreadCreate("TestMutex2", TestMutexThread2, &info, 110, 0);
   OS_ThreadCreate("TestMutex", TestMutexThread, &info, 50, 0);
 
 
 
   OS_ThreadSleep(50);
   printf("Posting mutexes at priority %d\n",
 
      OS_ThreadPriorityGet(OS_ThreadSelf()));
   OS_MutexPost(info.MyMutex);
   OS_MutexPost(info.MyMutex);
   OS_MutexPost(info.MyMutex);
   OS_MutexPost(info.MyMutex);
   OS_MutexPost(info.MyMutex);
   OS_MutexPost(info.MyMutex);
 
   printf("Thread priority %d\n", OS_ThreadPriorityGet(OS_ThreadSelf()));
 
   OS_ThreadSleep(50);
 
 
   printf("Try get mutex\n");
   printf("Try get mutex\n");
   OS_MutexPend(info.MyMutex);
   OS_MutexPend(info.MyMutex);
   printf("Gotit\n");
   printf("Gotit\n");
 
 
   OS_MutexDelete(info.MyMutex);
   OS_MutexDelete(info.MyMutex);
 
   OS_ThreadSleep(50);
   printf("Done.\n");
   printf("Done.\n");
}
}
 
 
//******************************************************************
//******************************************************************
static void TestMQueue(void)
static void TestMQueue(void)
Line 404... Line 418...
int SpinDone;
int SpinDone;
void ThreadSpin(void *arg)
void ThreadSpin(void *arg)
{
{
   int i;
   int i;
   int j = 0;
   int j = 0;
 
   unsigned int state;
   unsigned int timeStart = OS_ThreadTime();
   unsigned int timeStart = OS_ThreadTime();
 
 
   for(i = 0; i < 0x10000000; ++i)
   for(i = 0; i < 0x10000000; ++i)
   {
   {
 
      if((i & 0xff) == 0)
 
      {
 
         state = OS_CriticalBegin();
      j += i;
      j += i;
 
         OS_CriticalEnd(state);
 
      }
      if(OS_ThreadTime() - timeStart > 400)
      if(OS_ThreadTime() - timeStart > 400)
         break;
         break;
      if((i & 0xfffff) == 0)
      if((i & 0xfffff) == 0)
         printf("[%d] ", (int)arg);
         printf("[%d] ", (int)arg);
   }
   }
Line 562... Line 582...
      }
      }
   }
   }
}
}
 
 
 
 
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.