libgpac
Documentation of the core library of GPAC
Process and Threads

Threading and Mutual Exclusion. More...

+ Collaboration diagram for Process and Threads:

Modules

 Thread
 Thread processing.
 
 Mutex
 Mutual exclusion.
 
 Semaphore
 Semaphore.
 

Data Structures

struct  GF_SystemRTInfo
 run-time system info object More...
 

Enumerations

enum  { GF_RTI_ALL_PROCESSES_TIMES = 1 , GF_RTI_PROCESS_MEMORY = 1<<1 , GF_RTI_SYSTEM_MEMORY_ONLY = 1<<2 }
 

Functions

u32 gf_sys_get_process_id ()
 Gets process ID. More...
 
Bool gf_sys_get_rti (u32 refresh_time_ms, GF_SystemRTInfo *rti, u32 flags)
 Gets Run-Time info. More...
 

Detailed Description

Time manipulation tools.

This section documents the threading of the GPAC framework. These provide an easy way to implement safe multithreaded tools.

Available tools are thread, mutex and semaphore


Data Structure Documentation

◆ GF_SystemRTInfo

struct GF_SystemRTInfo

The Run-Time Info object is used to get CPU and memory occupation of the calling process. All time values are expressed in milliseconds (accuracy is not guaranteed).

Data Fields
u32 sampling_instant

start of the sampling period

u32 sampling_period_duration

duration of the sampling period

u32 total_cpu_time

total amount of time (User+kernel) spent in CPU for all processes as evaluated at the end of the sampling period

u32 process_cpu_time

total amount of time (User+kernel) spent in CPU for the calling process as evaluated at the end of the sampling period

u32 total_cpu_time_diff

amount of time (User+kernel) spent in CPU for all processes during the sampling period

u32 process_cpu_time_diff

total amount of time (User+kernel) spent in CPU for the calling process during the sampling period

u32 cpu_idle_time

total amount of idle time during the sampling period.

u32 total_cpu_usage

percentage (from 0 to 100) of CPU usage during the sampling period.

u32 process_cpu_usage

percentage (from 0 to 100) of the CPU usage by the calling process during the sampling period.

u32 pid

calling process ID

u32 thread_count

calling process thread count if known

u64 process_memory

size of calling process allocated heaps

u64 physical_memory

total physical memory in system

u64 physical_memory_avail

available physical memory in system

u64 gpac_memory

total memory currently allocated by gpac

u32 nb_cores

total number of cores on the system

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Selection flags for run-time info retrieval

Enumerator
GF_RTI_ALL_PROCESSES_TIMES 

Indicates all processes' times must be fetched. If not set, only the current process times will be retrieved, and the thread count and total times won't be available

GF_RTI_PROCESS_MEMORY 

Indicates the process allocated heap size must be fetch. If not set, only the system physical memory is fetched. Fetching the entire ocess allocated memory can have a large impact on performances

GF_RTI_SYSTEM_MEMORY_ONLY 

Indicates that only system memory should be fetched. When set, all refreshing info is ignored

Function Documentation

◆ gf_sys_get_process_id()

u32 gf_sys_get_process_id ( )

Gets ID of the process running this gpac instance.

Returns
the ID of the main process

◆ gf_sys_get_rti()

Bool gf_sys_get_rti ( u32  refresh_time_ms,
GF_SystemRTInfo rti,
u32  flags 
)

Gets CPU and memory usage info for the calling process and the system. Information gathering is controled through timeout values.

Parameters
refresh_time_msrefresh time period in milliseconds. If the last sampling was done less than this period ago, the run-time info is not refreshed.
rtiholder to the run-time info structure to update.
flagsspecify which info is to be retrieved.
Returns
1 if info has been updated, 0 otherwise.
Note
You should not try to use a too small refresh time. Typical values are 500 ms or one second.