cctools
work_queue_process.h
1 #ifndef WORK_QUEUE_PROCESS_H
2 #define WORK_QUEUE_PROCESS_H
3 
4 #include "work_queue.h"
5 #include "timestamp.h"
6 #include "path_disk_size_info.h"
7 
8 #include <unistd.h>
9 #include <sys/types.h>
10 #include <sys/resource.h>
11 
12 #define MAX_BUFFER_SIZE 4096
13 
14 /*
15 work_queue_process is a running instance of a work_queue_task.
16 This object is private to the work_queue_worker.
17 */
18 
20  pid_t pid;
21  int task_status; // Any of WORK_QUEUE_RESULT_*
22  int exit_status; // Exit code, or signal number to task process.
23 
24  struct rusage rusage;
25  timestamp_t execution_start;
26  timestamp_t execution_end;
27 
28  char *sandbox;
29  char *tmpdir; // TMPDIR per task, expected to be a subdir of sandbox.
30  char *output_file_name;
31  int output_fd;
32 
33  struct work_queue_task *task;
34 
35  /* expected disk usage by the process. If no cache is used, it is the same as in task. */
36  int64_t disk;
37  /* 1 if the task sandbox was mounted on a loop device. 0 otherwise. */
38  int loop_mount;
39 
40  /* disk size and number of files found in the process sandbox. */
41  int64_t sandbox_size;
42  int64_t sandbox_file_count;
43 
44  /* state between complete disk measurements. */
45  struct path_disk_size_info *disk_measurement_state;
46 };
47 
48 struct work_queue_process * work_queue_process_create( struct work_queue_task *task, int disk_allocation );
49 pid_t work_queue_process_execute( struct work_queue_process *p );
50 void work_queue_process_kill( struct work_queue_process *p );
51 void work_queue_process_delete( struct work_queue_process *p );
52 void work_queue_process_compute_disk_needed( struct work_queue_process *p );
53 
54 int work_queue_process_measure_disk(struct work_queue_process *p, int max_time_on_measurement);
55 
56 #endif
A task description.
Definition: work_queue.h:126
A manager-worker library.
Portable routines for high resolution timing.
UINT64_T timestamp_t
A type to hold the current time, in microseconds since January 1st, 1970.
Definition: timestamp.h:20
Definition: path_disk_size_info.h:13
Query disk space on the given directory.
Definition: work_queue_process.h:19