Skip to content

Instantly share code, notes, and snippets.

@galonsky
Created February 17, 2011 03:40
Show Gist options
  • Save galonsky/830922 to your computer and use it in GitHub Desktop.
Save galonsky/830922 to your computer and use it in GitHub Desktop.
#include "thread.h"
#include "interrupt.h"
#include <iostream>
using namespace std;
void thread2(void *arg)
{
char *lotsa_memory = new char[STACK_SIZE * 1000];
thread_lock(123);
thread_wait(123, 1);
thread_unlock(123);
}
void thread(void *arg)
{
start_preemptions(true, false, 0);
for(int i = 0; i < 10000000; i++)
{
thread_create((thread_startfunc_t) thread2, (void *) 0);
if(i % 10000 == 0)
{
thread_broadcast(123, 1);
}
}
}
int main()
{
if(thread_libinit((thread_startfunc_t) thread, (void *) 0) == -1)
{
cout << "Failure" << endl;
}
else
{
cout << "Success" << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment