Turnstone Operating System
Loading...
Searching...
No Matches
sync.h File Reference

synchronization interface More...

#include <types.h>
#include <memory.h>

Macros

#define ___CPU_SYNC_H   0
 
#define SYNC_LOCK_SIZE   0x28
 
#define lock_create_with_heap(h)   lock_create_with_heap_for_future(h, 0, 0)
 macro for creating lock with heap More...
 
#define lock_create()   lock_create_with_heap(NULL)
 macro for creating lock with default heap
 
#define lock_create_for_future(tid)   lock_create_with_heap_for_future(NULL, true, tid)
 macro for creating future lock with default heap
 
#define semaphore_create(c)   semaphore_create_with_heap(NULL, c)
 creats sempahore at default heap with count More...
 
#define semaphore_acquire(s)   semaphore_acquire_with_count(s, 1)
 acquires one slot at semaphore More...
 
#define semaphore_release(s)   semaphore_release_with_count(s, 1)
 releases one slot at semaphore More...
 

Typedefs

typedef struct lock_t lock_t
 
typedef struct semaphore_t semaphore_t
 

Functions

lock_tlock_create_with_heap_for_future (memory_heap_t *heap, boolean_t for_future, uint64_t task_id)
 creates lock More...
 
int8_t lock_destroy (lock_t *lock)
 destroys lock More...
 
void lock_acquire (lock_t *lock)
 acquires lock More...
 
void lock_release (lock_t *lock)
 relaases lock More...
 
semaphore_tsemaphore_create_with_heap (memory_heap_t *heap, uint64_t count)
 create semaphore More...
 
int8_t semaphore_destroy (semaphore_t *semaphore)
 destroys semaphore More...
 
int8_t semaphore_acquire_with_count (semaphore_t *semaphore, uint64_t count)
 acquires slots at semaphore More...
 
int8_t semaphore_release_with_count (semaphore_t *semaphore, uint64_t count)
 releases slots at semaphore More...
 

Detailed Description

synchronization interface

This work is licensed under TURNSTONE OS Public License. Please read and understand latest version of Licence.

Macro Definition Documentation

◆ ___CPU_SYNC_H

#define ___CPU_SYNC_H   0

prevent duplicate header error macro

◆ lock_create_with_heap

#define lock_create_with_heap (   h)    lock_create_with_heap_for_future(h, 0, 0)

macro for creating lock with heap

Parameters
[in]hheap

◆ semaphore_acquire

#define semaphore_acquire (   s)    semaphore_acquire_with_count(s, 1)

acquires one slot at semaphore

Parameters
[in]ssemaphore to acquire

◆ semaphore_create

#define semaphore_create (   c)    semaphore_create_with_heap(NULL, c)

creats sempahore at default heap with count

Parameters
[in]ccount

◆ semaphore_release

#define semaphore_release (   s)    semaphore_release_with_count(s, 1)

releases one slot at semaphore

Parameters
[in]ssemaphore to release

◆ SYNC_LOCK_SIZE

#define SYNC_LOCK_SIZE   0x28

memory size for lock

Typedef Documentation

◆ lock_t

typedef struct lock_t lock_t

lock type

◆ semaphore_t

typedef struct semaphore_t semaphore_t

semaphore type

Function Documentation

◆ lock_acquire()

void lock_acquire ( lock_t lock)

acquires lock

Parameters
[in]locklock to acquire

◆ lock_create_with_heap_for_future()

lock_t * lock_create_with_heap_for_future ( memory_heap_t heap,
boolean_t  for_future,
uint64_t  task_id 
)

creates lock

Parameters
[in]heapheap for lock
[in]for_futureis lock for future
Returns
lock

◆ lock_destroy()

int8_t lock_destroy ( lock_t lock)

destroys lock

Parameters
[in]locklock to destroy
Returns
0 if succeed

◆ lock_release()

void lock_release ( lock_t lock)

relaases lock

Parameters
[in]locklock to release

◆ semaphore_acquire_with_count()

int8_t semaphore_acquire_with_count ( semaphore_t semaphore,
uint64_t  count 
)

acquires slots at semaphore

Parameters
[in]semaphoresemaphore to acquire
[in]countsemaphore decrease value
Returns
0 if succeed, or waits

◆ semaphore_create_with_heap()

semaphore_t * semaphore_create_with_heap ( memory_heap_t heap,
uint64_t  count 
)

create semaphore

Parameters
[in]heapheap where semaphore resides
[in]countsemaphore count value
Returns
semaphore

◆ semaphore_destroy()

int8_t semaphore_destroy ( semaphore_t semaphore)

destroys semaphore

Parameters
[in]semaphoresemaphore to destroy

◆ semaphore_release_with_count()

int8_t semaphore_release_with_count ( semaphore_t semaphore,
uint64_t  count 
)

releases slots at semaphore

Parameters
[in]semaphoresemaphore to release
[in]countsemaphore increase value
Returns
0 if succeed