Skip to content

Commit

Permalink
updated examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Rajmund Szymanski committed Nov 16, 2018
1 parent ed60ee6 commit 1932b3e
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
File renamed without changes.
45 changes: 45 additions & 0 deletions examples/MemoryPool-2.cpp_
@@ -0,0 +1,45 @@
#include <stm32f4_discovery.h>
#include <os.h>

Led led;
ListTT<unsigned> *lst;
MemoryPoolTT<1, unsigned> *mem;
TaskT<512> *sla;
TaskT<768> *mas;

void slave()
{
unsigned*p;

lst->wait(&p);
led = *p;
mem->give(p);

ThisTask::stop();
}

void master()
{
unsigned*p;
unsigned x = 1;

for (;;)
{
sla = TaskT<512>::detached(0, slave);
ThisTask::delay(SEC);

mem->wait(&p);
*p=x;
lst->give(p);
x = (x << 1) | (x >> 3);
}
}

int main()
{
lst = ListTT<unsigned>::create();
mem = MemoryPoolTT<1, unsigned>::create();
mas = TaskT<768>::create(0, master);

ThisTask::stop();
}

0 comments on commit 1932b3e

Please sign in to comment.