Skip to content

Commit

Permalink
Renaming functions to standardise for cooperative thread context towa…
Browse files Browse the repository at this point in the history
…rd NanoCore renaming
  • Loading branch information
solariun committed Oct 30, 2019
1 parent b6a15a0 commit 02d5951
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 37 deletions.
20 changes: 10 additions & 10 deletions CorePartition/CorePartition.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,32 +329,32 @@ void CorePartition_Yield ()
}


size_t CorePartition_GetPartitionID()
size_t CorePartition_GetID()
{
return nCurrentThread;
}



size_t CorePartition_GetPartitionStackSize()
size_t CorePartition_GetStackSize()
{
return pCurrentThread->nStackSize;
}

size_t CorePartition_GetPartitionMaxStackSize()
size_t CorePartition_GetMaxStackSize()
{
return pCurrentThread->nStackMaxSize;
}


size_t CorePartition_GetPartitionAllocatedMemorySize(void)
size_t CorePartition_GetAllocatedMemorySize(void)
{
return CorePartition_GetThreadStructSize () + CorePartition_GetPartitionMaxStackSize ();
return CorePartition_GetThreadStructSize () + CorePartition_GetMaxStackSize ();
}

size_t CorePartition_GetPartitionUsedMemorySize(void)
size_t CorePartition_GetUsedMemorySize(void)
{
return CorePartition_GetThreadStructSize () + CorePartition_GetPartitionStackSize ();
return CorePartition_GetThreadStructSize () + CorePartition_GetStackSize ();
}


Expand All @@ -364,7 +364,7 @@ size_t CorePartition_GetThreadStructSize(void)
}


bool CorePartition_IsAllCoresStarted(void)
bool CorePartition_IsAllThreadsStarted(void)
{
return nStartedCores == nMaxThreads;
}
Expand All @@ -376,13 +376,13 @@ bool CorePartition_IsCoreRunning(void)
}


uint32_t CorePartition_GetCoreNice()
uint32_t CorePartition_GetNice()
{
return pCurrentThread->nNice;
}


void CorePartition_SetCoreNice (uint32_t nNice)
void CorePartition_SetNice (uint32_t nNice)
{
pCurrentThread->nNice = nNice == 0 ? 1 : nNice;
}
16 changes: 8 additions & 8 deletions CorePartition/CorePartition.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,24 +60,24 @@ extern "C"{

void CorePartition_Yield(void);

size_t CorePartition_GetPartitionID(void);
size_t CorePartition_GetID(void);

size_t CorePartition_GetPartitionStackSize(void);
size_t CorePartition_GetPartitionMaxStackSize(void);
size_t CorePartition_GetStackSize(void);
size_t CorePartition_GetMaxStackSize(void);


size_t CorePartition_GetPartitionUsedMemorySize(void);
size_t CorePartition_GetPartitionAllocatedMemorySize(void);
size_t CorePartition_GetUsedMemorySize(void);
size_t CorePartition_GetAllocatedMemorySize(void);

size_t CorePartition_GetThreadStructSize (void);

size_t CorePartition_GetThreadStructSize(void);

bool CorePartition_IsAllCoresStarted(void);
bool CorePartition_IsAllThreadsStarted(void);

uint32_t CorePartition_GetCoreNice(void);
uint32_t CorePartition_GetNice(void);

void CorePartition_SetCoreNice (uint32_t nNice);
void CorePartition_SetNice (uint32_t nNice);

#ifdef __cplusplus
} // extern "C"
Expand Down
2 changes: 1 addition & 1 deletion CorePartition/Resources/BlinkThreads/BlinkThreads.ino
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void Delay (uint64_t nSleep)

void Thread1 ()
{
uint8_t nPin = CorePartition_GetPartitionID() + 1;
uint8_t nPin = CorePartition_GetID() + 1;

pinMode (nPin, OUTPUT);

Expand Down
16 changes: 8 additions & 8 deletions CorePartition/Resources/LowMemoryExample/LowMemoryExample.ino
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ void Thread1 ()
Serial.print (", Sleep Time: ");
Serial.print (millis() - start);
Serial.print (", ");
Serial.print (CorePartition_GetCoreNice ());
Serial.print (CorePartition_GetNice ());
Serial.println ("\n");

Serial.flush();
Expand All @@ -142,13 +142,13 @@ void Thread2 ()
Serial.print (", Sleep Time: ");
Serial.print (millis() - start); start = millis();
Serial.print (", Nice: ");
Serial.print (CorePartition_GetCoreNice());
Serial.print (CorePartition_GetNice());
Serial.print (", CTX: [");
Serial.print (CorePartition_GetThreadStructSize ());
Serial.print ("] bytes, Stack (used/max): [");
Serial.print (CorePartition_GetPartitionStackSize ());
Serial.print (CorePartition_GetStackSize ());
Serial.print ("/");
Serial.print (CorePartition_GetPartitionMaxStackSize ());
Serial.print (CorePartition_GetMaxStackSize ());
Serial.println ("]\n");


Expand All @@ -171,7 +171,7 @@ void Thread3 ()
Serial.print (", Sleep Time: ");
Serial.print (millis() - start); //start = millis();
Serial.print (", Nice: ");
Serial.print (CorePartition_GetCoreNice());
Serial.print (CorePartition_GetNice());
Serial.println ("\n");

Serial.flush ();
Expand All @@ -195,7 +195,7 @@ void Thread4 ()
Serial.print (", Sleep Time: ");
Serial.print (millis() - start); //start = millis();
Serial.print (", Nice: ");
Serial.print (CorePartition_GetCoreNice());
Serial.print (CorePartition_GetNice());
Serial.println ("\n");

Serial.flush ();
Expand All @@ -214,13 +214,13 @@ void Thread5 ()
while (1)
{
Serial.print ("\e[14;10H\e[K>> Thread");
Serial.print (CorePartition_GetPartitionID()+1);
Serial.print (CorePartition_GetID()+1);
Serial.print (": ");
Serial.print (nValue++);
Serial.print (", Sleep Time: ");
Serial.print (millis() - start); //start = millis();
Serial.print (", Nice: ");
Serial.print (CorePartition_GetCoreNice());
Serial.print (CorePartition_GetNice());
Serial.println ("\n");

Serial.flush ();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ void Thread1 ()
Serial.print (", Sleep Time: ");
Serial.print (millis() - start);
Serial.print (", ");
Serial.print (CorePartition_GetCoreNice ());
Serial.print (CorePartition_GetNice ());
Serial.print (", nImagesItens [ ");
Serial.print (nImagesItens);
Serial.print ("]");
Expand Down Expand Up @@ -341,15 +341,15 @@ void Thread2 ()
Serial.print (millis() - start); start = millis();
Serial.print (" millis");
Serial.print (", StackSize: ");
Serial.print (CorePartition_GetPartitionStackSize());
Serial.print (CorePartition_GetStackSize());
Serial.print (", Nice: ");
Serial.print (CorePartition_GetCoreNice());
Serial.print (CorePartition_GetNice());
Serial.print (", struct Size: [");
Serial.print (CorePartition_GetThreadStructSize ());
Serial.print ("] bytes, Core Mem: [");
Serial.print (CorePartition_GetPartitionUsedMemorySize ());
Serial.print (CorePartition_GetUsedMemorySize ());
Serial.print (" from ");
Serial.print (CorePartition_GetPartitionAllocatedMemorySize ());
Serial.print (CorePartition_GetAllocatedMemorySize ());
Serial.println ("]\n");

fMin = 1000, fMax = 0;
Expand Down Expand Up @@ -403,7 +403,7 @@ void Thread3 ()
Serial.print (", Sleep Time: ");
Serial.print (millis() - start); //start = millis();
Serial.print (", Nice: ");
Serial.print (CorePartition_GetCoreNice());
Serial.print (CorePartition_GetNice());
Serial.println ("\n");

Serial.flush ();
Expand Down
6 changes: 3 additions & 3 deletions CorePartition/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void Thread1 ()

while (1)
{
printf (">> %lu: Value: [%u] - ScructSize: [%zu] - Memory: [%zu]\n", CorePartition_GetPartitionID(), nValue++, CorePartition_GetThreadStructSize(), CorePartition_GetPartitionAllocatedMemorySize());
printf (">> %lu: Value: [%u] - ScructSize: [%zu] - Memory: [%zu]\n", CorePartition_GetID(), nValue++, CorePartition_GetThreadStructSize(), CorePartition_GetAllocatedMemorySize());
CorePartition_Yield (); //Sleep (10);
}
}
Expand All @@ -84,7 +84,7 @@ void Thread2 ()

while (1)
{
printf ("** %lu: Value: [%u]\n", CorePartition_GetPartitionID(), nValue++);
printf ("** %lu: Value: [%u]\n", CorePartition_GetID(), nValue++);

CorePartition_Yield(); //Sleep (10);
}
Expand All @@ -100,7 +100,7 @@ void Thread3 ()

while (1)
{
printf ("## %lu: Value: [%u]\n", CorePartition_GetPartitionID(), nValue++);
printf ("## %lu: Value: [%u]\n", CorePartition_GetID(), nValue++);

CorePartition_Yield(); //Sleep (10);

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Version 2.2

![License information](https://raw.githubusercontent.com/solariun/CorePartition/master/License.png)

Partitioning a CORE into several Threads with a fast schedule that can be specialised using Tick and ticksleep interface, this way you can use nanoseconds, milliseconds or even real ticks to predict time, turning it into a powerful real time processor. This lib was designed to work, virtually, with any modern micro controller or Microchip as long as it uses reverse bottom - up stack addressing, but was aiming single core processors and user space like MSDOS, linux applications, windows applications and Mac to replace pthread for a more controled execution envirionment.
Partitioning a CORE into several Threads with a fast scheduler capable to be specialised through Tick and ticksleep interface, this way you can use nanoseconds, milliseconds or even real ticks to predict time, turning it into a powerful real time processor. This lib was designed to work, virtually, with any modern micro controller or Microchip as long as it uses reverse bottom - up stack addressing, but was aiming single core processors and user space like MSDOS, linux applications, windows applications and Mac to replace pthread for a more controled execution envirionment.

HIGHLY suitable for Arduino (All official models included) as well, a .ino project is also provided with an example.

Expand Down

0 comments on commit 02d5951

Please sign in to comment.