milk  1.01
Modular Image processing Library toolKit
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 "CommandLineInterface/timeutils.h"
#include "CLIcore.h"
#include "COREMOD_tools/COREMOD_tools.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 PROCCTRL_DISPLAYMODE_HELP   1
 
#define PROCCTRL_DISPLAYMODE_CTRL   2
 
#define PROCCTRL_DISPLAYMODE_RESOURCES   3
 
#define PROCCTRL_DISPLAYMODE_TRIGGER   4
 
#define PROCCTRL_DISPLAYMODE_TIMING   5
 
#define PROCCTRL_DISPLAYMODE_HTOP   6
 
#define PROCCTRL_DISPLAYMODE_IOTOP   7
 
#define PROCCTRL_DISPLAYMODE_ATOP   8
 
#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)
 
errno_t processinfo_waitoninputstream_init (PROCESSINFO *processinfo, imageID trigID, int triggermode, int semindexrequested)
 Set up input wait stream. More...
 
errno_t processinfo_waitoninputstream (PROCESSINFO *processinfo)
 Wait on a stream. More...
 
errno_t processinfo_update_output_stream (PROCESSINFO *processinfo, imageID outstreamID)
 Update ouput stream at completion of processinfo-enabled loop iteration. More...
 
int processinfo_exec_start (PROCESSINFO *processinfo)
 
int processinfo_exec_end (PROCESSINFO *processinfo)
 
static int processtools__print_header (const char *str, char c)
 
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)

Function Documentation

◆ 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

◆ 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_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_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_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_update_output_stream()

errno_t processinfo_update_output_stream ( PROCESSINFO processinfo,
imageID  outstreamID 
)

Update ouput stream at completion of processinfo-enabled loop iteration.

◆ processinfo_waitoninputstream()

errno_t processinfo_waitoninputstream ( PROCESSINFO processinfo)

Wait on a stream.

◆ processinfo_waitoninputstream_init()

errno_t processinfo_waitoninputstream_init ( PROCESSINFO processinfo,
imageID  trigID,
int  triggermode,
int  semindexrequested 
)

Set up input wait stream.

Specify stream on which the loop process will be triggering, and what is the trigger mode.

The actual trigger mode may be different from the requested trigger mode.

The standard option should be tiggermode = PROCESSINFO_TRIGGERMODE_SEMAPHORE and semindex = -1, which will automatically find a suitable semaphore