Skip to content
Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
104 lines (77 sloc) 3.08 KB

Stratify OS Documentation

Getting Started

The Stratify web application is the place to get started. After you login, you will be able to install the sl command line tool that is used to manage all aspects of the Stratify OS ecosystem from OS packages, to applications, to data in the cloud.

Guides

If you are brand new to Stratify OS, these guides are a good place to start. Stratify OS is not like any other microcontroller operating system in existence.

sl Manual

The sl command line tool is used to manage Stratify OS applications, data, and OS packages. To read about its capabilites, see the manual.

API Reference

Stratify OS applications can be built using the StratifyAPI library which is an embedded friendly C++ library for many POSIX and standard C library functions. Or they can be built using direct calls to POSIX and standard C library functions.

Thread Example

The following is an example of using the StratifyAPI to create a thread versus using POSIX directly.

//Using the StratifyAPI
#include <sapi/sys.hpp>

void * thread_function(void * args){
    u32 * argument = (u32*)args;
    //execute thread stuff
    //*argument is equal to 10
    return NULL;
}

int main(int argc, char * argv[]){
    Thread thread;
    u32 argument = 10;
    thread.create(thread_function, &argument);
    thread.wait();
}
//Using POSIX
#include <pthread.h>

void * thread_function(void * args){
    
    u32 * argument = (u32*)args;
    //execute thread stuff

    //*argument is equal to 10

    return NULL;
}

int main(int argc, char * argv[]){
    pthread_t t;
    pthread_attr_t attr;

    if ( pthread_attr_init(&attr) < 0 ){
        perror("failed to initialize attr");
        return -1;
    }

    if ( pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED) < 0 ){
        perror("failed to set detach state");
        return -1;
    }

    if ( pthread_attr_setstacksize(&attr, 4096) < 0 ){
        perror("failed to set stack size");
        return -1;
    }

    if ( pthread_create(&t, &attr, thread_function, NULL) ){
        perror("failed to create thread");
        return -1;
    }

    //this just checks to see if the thread is still valid (doesn't send a signal)
    while( pthread_kill(t, 0) == 0 ){
        usleep(100*1000);
    }
    return 0;
}
You can’t perform that action at this time.