diff --git a/CorePartition/CorePartition.c b/CorePartition/CorePartition.c index 177c0c3..b79d339 100644 --- a/CorePartition/CorePartition.c +++ b/CorePartition/CorePartition.c @@ -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 (); } @@ -364,7 +364,7 @@ size_t CorePartition_GetThreadStructSize(void) } -bool CorePartition_IsAllCoresStarted(void) +bool CorePartition_IsAllThreadsStarted(void) { return nStartedCores == nMaxThreads; } @@ -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; } diff --git a/CorePartition/CorePartition.h b/CorePartition/CorePartition.h index fd8d364..719a7a3 100644 --- a/CorePartition/CorePartition.h +++ b/CorePartition/CorePartition.h @@ -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" diff --git a/CorePartition/Resources/BlinkThreads/BlinkThreads.ino b/CorePartition/Resources/BlinkThreads/BlinkThreads.ino index a09e5ef..3c0dabd 100644 --- a/CorePartition/Resources/BlinkThreads/BlinkThreads.ino +++ b/CorePartition/Resources/BlinkThreads/BlinkThreads.ino @@ -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); diff --git a/CorePartition/Resources/LowMemoryExample/LowMemoryExample.ino b/CorePartition/Resources/LowMemoryExample/LowMemoryExample.ino index 47e7a76..b95b63a 100644 --- a/CorePartition/Resources/LowMemoryExample/LowMemoryExample.ino +++ b/CorePartition/Resources/LowMemoryExample/LowMemoryExample.ino @@ -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(); @@ -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"); @@ -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 (); @@ -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 (); @@ -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 (); diff --git a/CorePartition/Resources/ThrermalCameraDemo/ThrermalCameraDemo.ino b/CorePartition/Resources/ThrermalCameraDemo/ThrermalCameraDemo.ino index 456cb64..896ac69 100644 --- a/CorePartition/Resources/ThrermalCameraDemo/ThrermalCameraDemo.ino +++ b/CorePartition/Resources/ThrermalCameraDemo/ThrermalCameraDemo.ino @@ -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 ("]"); @@ -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; @@ -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 (); diff --git a/CorePartition/main.cpp b/CorePartition/main.cpp index 4840d54..736589d 100644 --- a/CorePartition/main.cpp +++ b/CorePartition/main.cpp @@ -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); } } @@ -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); } @@ -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); diff --git a/README.md b/README.md index 1e7f90e..ed74720 100644 --- a/README.md +++ b/README.md @@ -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.