cacao  Release 0.1.03-dev
Compute And Control For Adaptive Optics
processtools.c File Reference

Tools to manage processes. More...

#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/file.h>
#include <malloc.h>
#include <sys/mman.h>
#include <time.h>
#include <signal.h>
#include <termios.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <ncurses.h>
#include <fcntl.h>
#include <ctype.h>
#include <dirent.h>
#include <wchar.h>
#include <locale.h>
#include <pthread.h>
#include "CLIcore.h"
#include <00CORE/00CORE.h>
#include "COREMOD_tools/COREMOD_tools.h"
#include "info/info.h"
#include <processtools.h>
Include dependency graph for processtools.c:

Macros

#define PROCESSINFO_ENABLED
 
#define _GNU_SOURCE
 
#define SHAREDPROCDIR   data.shmdir
 
#define CMDPROC_CONTEXTSWITCH   1
 
#define CMDPROC_CPUUSE   1
 
#define CMDPROC_MEMUSE   1
 
#define CMDPROC_PROCSTAT   1
 
#define NBtopMax   5000
 

Typedefs

typedef int errno_t
 

Functions

errno_t processinfo_procdirname (char *procdname)
 
PROCESSINFOprocessinfo_setup (char *pinfoname, char descriptionstring[200], char msgstring[200], const char *functionname, const char *filename, int linenumber)
 
errno_t processinfo_error (PROCESSINFO *processinfo, char *errmsgstring)
 
errno_t processinfo_loopstart (PROCESSINFO *processinfo)
 
int processinfo_loopstep (PROCESSINFO *processinfo)
 
int processinfo_compute_status (PROCESSINFO *processinfo)
 
long processinfo_shm_list_create ()
 
PROCESSINFOprocessinfo_shm_create (const char *pname, int CTRLval)
 
PROCESSINFOprocessinfo_shm_link (const char *pname, int *fd)
 
int processinfo_shm_close (PROCESSINFO *pinfo, int fd)
 
int processinfo_cleanExit (PROCESSINFO *processinfo)
 
int processinfo_SIGexit (PROCESSINFO *processinfo, int SignalNumber)
 
int processinfo_WriteMessage (PROCESSINFO *processinfo, const char *msgstring)
 
int processinfo_CatchSignals ()
 
int processinfo_ProcessSignals (PROCESSINFO *processinfo)
 
int processinfo_exec_start (PROCESSINFO *processinfo)
 
int processinfo_exec_end (PROCESSINFO *processinfo)
 
static errno_t initncurses ()
 
int GetNumberCPUs (PROCINFOPROC *pinfop)
 
static int GetCPUloads (PROCINFOPROC *pinfop)
 
static int PIDcollectSystemInfo (PROCESSINFODISP *pinfodisp, int level)
 
int processinfo_CPUsets_List (STRINGLISTENTRY *CPUsetList)
 
int processinfo_SelectFromList (STRINGLISTENTRY *StringList, int NBelem)
 
void * processinfo_scan (void *thptr)
 
void processinfo_CTRLscreen_atexit ()
 
void processinfo_CTRLscreen_handle_winch (int __attribute__((unused)) sig)
 
errno_t processinfo_CTRLscreen ()
 

Variables

static int CTRLscreenExitLine = 0
 
static PROCESSINFOLISTpinfolist
 
static int wrow
 
static int wcol
 
static int wcolmax
 
static struct timespec t1
 
static struct timespec t2
 
static struct timespec tdiff
 
static double scantime_cpuset
 
static double scantime_status
 
static double scantime_stat
 
static double scantime_pstree
 
static double scantime_top
 
static double scantime_CPUload
 
static double scantime_CPUpcnt
 

Detailed Description

Tools to manage processes.

Manages structure PROCESSINFO.

See also
Process Info Structure (processinfo)

Macro Definition Documentation

◆ _GNU_SOURCE

#define _GNU_SOURCE

◆ CMDPROC_CONTEXTSWITCH

#define CMDPROC_CONTEXTSWITCH   1

◆ CMDPROC_CPUUSE

#define CMDPROC_CPUUSE   1

◆ CMDPROC_MEMUSE

#define CMDPROC_MEMUSE   1

◆ CMDPROC_PROCSTAT

#define CMDPROC_PROCSTAT   1

◆ NBtopMax

#define NBtopMax   5000

◆ PROCESSINFO_ENABLED

#define PROCESSINFO_ENABLED

◆ SHAREDPROCDIR

#define SHAREDPROCDIR   data.shmdir

Typedef Documentation

◆ errno_t

typedef int errno_t

Function Documentation

◆ GetCPUloads()

static int GetCPUloads ( PROCINFOPROC pinfop)
static

◆ GetNumberCPUs()

int GetNumberCPUs ( PROCINFOPROC pinfop)

Purpose

detects the number of CPU and fill the cpuids

Description

populates cpuids array with the global system PU numbers in the physical order: [PU0 of CPU0, PU1 of CPU0, ... PU0 of CPU1, PU1 of CPU1, ...]

◆ initncurses()

static errno_t initncurses ( )
static

INITIALIZE ncurses

◆ PIDcollectSystemInfo()

static int PIDcollectSystemInfo ( PROCESSINFODISP pinfodisp,
int  level 
)
static

◆ processinfo_CatchSignals()

int processinfo_CatchSignals ( )

◆ processinfo_cleanExit()

int processinfo_cleanExit ( PROCESSINFO processinfo)

◆ processinfo_compute_status()

int processinfo_compute_status ( PROCESSINFO processinfo)

◆ processinfo_CPUsets_List()

int processinfo_CPUsets_List ( STRINGLISTENTRY CPUsetList)

Purpose

Creates list of CPU sets

Description

Uses command: cset set -l

◆ processinfo_CTRLscreen()

errno_t processinfo_CTRLscreen ( )

Purpose

Control screen for PROCESSINFO structures

Description

Relies on ncurses for display

Display

◆ processinfo_CTRLscreen_atexit()

void processinfo_CTRLscreen_atexit ( )

◆ processinfo_CTRLscreen_handle_winch()

void processinfo_CTRLscreen_handle_winch ( int __attribute__((unused))  sig)

◆ processinfo_error()

errno_t processinfo_error ( PROCESSINFO processinfo,
char *  errmsgstring 
)

◆ processinfo_exec_end()

int processinfo_exec_end ( PROCESSINFO processinfo)

◆ processinfo_exec_start()

int processinfo_exec_start ( PROCESSINFO processinfo)

◆ processinfo_loopstart()

errno_t processinfo_loopstart ( PROCESSINFO processinfo)

◆ processinfo_loopstep()

int processinfo_loopstep ( PROCESSINFO processinfo)

◆ processinfo_procdirname()

errno_t processinfo_procdirname ( char *  procdname)

◆ processinfo_ProcessSignals()

int processinfo_ProcessSignals ( PROCESSINFO processinfo)

◆ processinfo_scan()

void* processinfo_scan ( void *  thptr)

Purpose

Scan function for processinfo CTRL

Description

Runs in background loop as thread initiated by processinfo_CTRL

Build a time-sorted list of processes

◆ processinfo_SelectFromList()

int processinfo_SelectFromList ( STRINGLISTENTRY StringList,
int  NBelem 
)

◆ processinfo_setup()

PROCESSINFO* processinfo_setup ( char *  pinfoname,
char  descriptionstring[200],
char  msgstring[200],
const char *  functionname,
const char *  filename,
int  linenumber 
)

◆ processinfo_shm_close()

int processinfo_shm_close ( PROCESSINFO pinfo,
int  fd 
)

◆ processinfo_shm_create()

PROCESSINFO* processinfo_shm_create ( const char *  pname,
int  CTRLval 
)

Create PROCESSINFO structure in shared memory

The structure holds real-time information about a process, so its status can be monitored and controlled See structure PROCESSINFO in CLLIcore.h for details

◆ processinfo_shm_link()

PROCESSINFO* processinfo_shm_link ( const char *  pname,
int *  fd 
)

◆ processinfo_shm_list_create()

long processinfo_shm_list_create ( )

Purpose

Read/create processinfo list

Description

If list does not exist, create it and return index = 0

If list exists, return first available index

◆ processinfo_SIGexit()

int processinfo_SIGexit ( PROCESSINFO processinfo,
int  SignalNumber 
)

◆ processinfo_WriteMessage()

int processinfo_WriteMessage ( PROCESSINFO processinfo,
const char *  msgstring 
)

Variable Documentation

◆ CTRLscreenExitLine

int CTRLscreenExitLine = 0
static

◆ pinfolist

PROCESSINFOLIST* pinfolist
static

◆ scantime_CPUload

double scantime_CPUload
static

◆ scantime_CPUpcnt

double scantime_CPUpcnt
static

◆ scantime_cpuset

double scantime_cpuset
static

◆ scantime_pstree

double scantime_pstree
static

◆ scantime_stat

double scantime_stat
static

◆ scantime_status

double scantime_status
static

◆ scantime_top

double scantime_top
static

◆ t1

struct timespec t1
static

◆ t2

struct timespec t2
static

◆ tdiff

struct timespec tdiff
static

◆ wcol

int wcol
static

◆ wcolmax

int wcolmax
static

◆ wrow

int wrow
static