Serene Runtime 1.0.0-dev
C runtime for the Serene programming language
Loading...
Searching...
No Matches
hello.c File Reference
#include <stdio.h>
#include "serene/runtime.h"
Include dependency graph for hello.c:

Go to the source code of this file.

Functions

static srn_fiber_result_t say_hello (srn_context_t *ctx, void *arg)
int main (void)

Variables

static int ok

Function Documentation

◆ main()

int main ( void )

Definition at line 37 of file hello.c.

37 {
38 SERENE_RUNTIME_INIT_WITH_SCHED(engine, sched, nullptr);
39 srn_context_t *ctx = srn_context_make(engine);
40
41 (void)srn_fiber_make(ctx, sched, say_hello, NULL, 0);
42 srn_sched_run(sched, 1);
43
44 // The manager reclaims every context chain at shutdown, so the context
45 // needs no separate release here.
47 return 0;
48}
static srn_fiber_result_t say_hello(srn_context_t *ctx, void *arg)
Definition 01_hello.c:34
srn_context_t * srn_context_make(srn_engine_t *engine)
Make an empty context, by allocating a new memory block.
Definition context.c:39
srn_fiber_t * srn_fiber_make(srn_context_t *ctx, srn_scheduler_t *sched, const char *name, srn_fiber_entry_t entry, void *arg, size_t stack_size)
Create a fiber that will run entry(ctx, arg), registered with sched but NOT scheduled.
Definition fiber.c:201
#define SERENE_RUNTIME_SHUTDOWN(engine)
Tear down what SERENE_RUNTIME_INIT brought up, in reverse order, the engine (reactor,...
Definition runtime.h:58
#define SERENE_RUNTIME_INIT_WITH_SCHED(engine, sched, config)
SERENE_RUNTIME_INIT plus a sched variable bound to the engine's scheduler, which every run and fiber ...
Definition runtime.h:46
void srn_sched_run(srn_scheduler_t *sched, size_t nworkers)
Run the scheduler with nworkers os threads draining it, returning once the pool goes quiescent (every...
Definition scheduler.c:843
Here is the call graph for this function:

◆ say_hello()

srn_fiber_result_t say_hello ( srn_context_t * ctx,
void * arg )
static

Definition at line 30 of file hello.c.

30 {
31 (void)ctx;
32 (void)arg;
33 printf("hello from a Serene fiber (substrate runtime)\n");
34 return &ok;
35}
static int ok
Definition hello.c:28

Variable Documentation

◆ ok

int ok
static

Definition at line 28 of file hello.c.