• Skip to main content
  • Skip to header right navigation
  • Skip to site footer
CDP Studio logo

CDP Studio

The no-code and full-code software development tool for distributed control systems and HMI

  • Why CDP
    • Software developers
    • Automation engineers
    • Managers
  • Product
    • Design UI
    • Develop
    • Analyze and test
    • Deploy
    • Framework and toolbox
    • Compatibility
  • Services
  • Use cases
  • Pricing
  • Try CDP

CDP Studio Documentation

  • Framework - CDP Core
  • <OSAPIProcess> - OSAPIProcess
  • 4.11.14

<OSAPIProcess> - OSAPIProcess

The OSAPIProcess provides methods for controlling and monitoring threads and processes. More...

Functions

double OSAPIGetApplicationMemoryUsed()
OSAPITASK_ID_TYPE OSAPIGetCurrentThreadId(void)
CDP::ProcessPriority OSAPIGetProcessPriority()
int OSAPIGetThreadPolicy(OSAPITASK_HANDLE_TYPE threadHandle = 0)
CDP::ThreadPriority OSAPIGetThreadPriority(OSAPITASK_HANDLE_TYPE threadHandle = 0)
double OSAPIReadCPULoad()
double OSAPIReadMemoryFree(double *free = 0, double *total = 0)
int OSAPISelect(const std::vector<OSAPIFILEDESCRIPTOR> &fds, fd_set *fdset, unsigned int timeoutMs)
void OSAPISetProcessPriority(CDP::ProcessPriority priority)
void OSAPISetThreadPriority(CDP::ThreadPriority priority, OSAPITASK_HANDLE_TYPE threadHandle = 0)
void OSAPISleep(unsigned int ms)
void OSAPISleep(unsigned int ms, unsigned int us)
void OSAPISystemMonitorsInit()
void OSAPIWaitForThreadToExit(OSAPITASK_HANDLE_TYPE hHandle, unsigned long ms = INFINITE)

Macros

OSAPITASK_HANDLE_TYPE
OSAPITASK_ID_TYPE

Function Documentation

double OSAPIGetApplicationMemoryUsed()

Returns the amount of memory used.

OSAPITASK_ID_TYPE OSAPIGetCurrentThreadId(void)

Returns the Operating System dependent Thread Id.

Note: The type of the thread handle is not only OS specific, but also platform dependent. Usage of this function should be wrapped in #if INSTALLATION==WINDOWS or #if INSTALLATION==LINUX

CDP::ProcessPriority OSAPIGetProcessPriority()

Returns the process priority or CDP::UnknownProcessPriority on failure.

See also OSAPISetProcessPriority.

int OSAPIGetThreadPolicy(OSAPITASK_HANDLE_TYPE threadHandle = 0)

Only implemented on Linux. Returns the policy of the calling thread or OSAPITASK_POLICY_INVALID on failure. Value SCHED_OTHER (0) is returned if _POSIX_THREAD_PRIORITY_SCHEDULING is not supported.

See also OSAPISetThreadPriority.

CDP::ThreadPriority OSAPIGetThreadPriority(OSAPITASK_HANDLE_TYPE threadHandle = 0)

Returns the priority of the calling thread threadHandle or CDP::UnknownThreadPriority on failure.

See also OSAPISetThreadPriority.

double OSAPIReadCPULoad()

Monitor cpu load, returns time busy / time idle as a number between 0 and 1.

double OSAPIReadMemoryFree(double *free = 0, double *total = 0)

Monitor memory load, returns memory free bytes.

int OSAPISelect(const std::vector<OSAPIFILEDESCRIPTOR> &fds, fd_set *fdset, unsigned int timeoutMs)

Wrapper of select() function. Example:

// signaller thread:
OSAPIEventWithFd osapiEvent;
osapiEvent.Set();
...
// listener thread:
#include <OSAPI/Process/OSAPIProcess.h>

std::vector<OSAPIFILEDESCRIPTOR> fds;
fd_set fdset;
fds.push_back(osapiEvent.GetFd());

int ret = OSAPISelect(fds, &fdset, 10);
if(ret >= 0)
{
  if(ret > 0)
  {
    if(FD_ISSET(osapiEvent.GetFd(), &fdset))
    {
      // osapiEvent received!
    }
  }
}
else
{
  // error handling
}

void OSAPISetProcessPriority(CDP::ProcessPriority priority)

Sets this application process priority to priority

See also OSAPIGetProcessPriority.

void OSAPISetThreadPriority(CDP::ThreadPriority priority, OSAPITASK_HANDLE_TYPE threadHandle = 0)

Set thread priority for calling thread threadHandle.

See also OSAPIGetThreadPriority.

void OSAPISleep(unsigned int ms)

Release cpu for specified time interval in ms.

void OSAPISleep(unsigned int ms, unsigned int us)

Release cpu for specified time interval in msecs, usecs. Do not set too low, or the OS will spend all its time checking the timer.

Note: Do not expect microsecond resolution on this call on Windows platforms.

void OSAPISystemMonitorsInit()

Initializes system monitors.

void OSAPIWaitForThreadToExit(OSAPITASK_HANDLE_TYPE hHandle, unsigned long ms = INFINITE)

Suspends current thread until thread with hHandle exits. Note: Linux waits infinitely for process to exit.

Macro Documentation

OSAPITASK_HANDLE_TYPE

Task/thread handle. pthread_t on Linux. HANDLE on Windows.

OSAPITASK_ID_TYPE

Task/thread id. pthread_t on Linux. unsigned long on Windows.

The content of this document is confidential information not to be published without the consent of CDP Technologies AS.

CDP Technologies AS, www.cdpstudio.com

Get started with CDP Studio today

Let us help you take your great ideas and turn them into the products your customer will love.

Try CDP Studio for free
Why CDP Studio?

CDP Technologies AS
Hundsværgata 8,
P.O. Box 144
6001 Ålesund, Norway

Tel: +47 990 80 900
E-mail: info@cdptech.com

Company

About CDP

Contact us

Services

Partners

Blog

Developers

Get started

User manuals

Support

Document download

Release notes

Follow CDP

  • LinkedIn
  • YouTube
  • GitHub

    © Copyright 2022 CDP Technologies. Privacy and cookie policy.

    Return to top