From c5e6af664ca88d08fa0fb2cfc910b125d4c47b73 Mon Sep 17 00:00:00 2001 From: Bryan Ward Date: Thu, 18 Apr 2013 16:34:51 -0400 Subject: DGL testing. --- bin/dgl_test.c | 157 --------------------------------------------------------- 1 file changed, 157 deletions(-) delete mode 100644 bin/dgl_test.c (limited to 'bin/dgl_test.c') diff --git a/bin/dgl_test.c b/bin/dgl_test.c deleted file mode 100644 index 22a13ae..0000000 --- a/bin/dgl_test.c +++ /dev/null @@ -1,157 +0,0 @@ -/* based_task.c -- A basic real-time task skeleton. - * - * This (by itself useless) task demos how to setup a - * single-threaded LITMUS^RT real-time task. - */ - -/* First, we include standard headers. - * Generally speaking, a LITMUS^RT real-time task can perform any - * system call, etc., but no real-time guarantees can be made if a - * system call blocks. To be on the safe side, only use I/O for debugging - * purposes and from non-real-time sections. - */ -#include -#include -#include - -/* Second, we include the LITMUS^RT user space library header. - * This header, part of liblitmus, provides the user space API of - * LITMUS^RT. - */ -#include "litmus.h" - -/* Next, we define period and execution cost to be constant. - * These are only constants for convenience in this example, they can be - * determined at run time, e.g., from command line parameters. - */ -#define PERIOD 100 -#define EXEC_COST 10 - -/* Catch errors. - */ -#define CALL( exp ) do { \ - int ret; \ - ret = exp; \ - if (ret != 0) \ - fprintf(stderr, "%s failed: %m\n", #exp);\ - else \ - fprintf(stderr, "%s ok.\n", #exp); \ - } while (0) - - -/* Declare the periodically invoked job. - * Returns 1 -> task should exit. - * 0 -> task should continue. - */ -int job(void); - -/* typically, main() does a couple of things: - * 1) parse command line parameters, etc. - * 2) Setup work environment. - * 3) Setup real-time parameters. - * 4) Transition to real-time mode. - * 5) Invoke periodic or sporadic jobs. - * 6) Transition to background mode. - * 7) Clean up and exit. - * - * The following main() function provides the basic skeleton of a single-threaded - * LITMUS^RT real-time task. In a real program, all the return values should be - * checked for errors. - */ -int main(int argc, char** argv) -{ - //int do_exit; - int fd, od_org, od_new; - int* resource; - int mask; - - /* The task is in background mode upon startup. */ - - - /***** - * 1) Command line paramter parsing would be done here. - */ - - /***** - * 2) Work environment (e.g., global data structures, file data, etc.) would - * be setup here. - */ - - CALL(fd = open(".dgl_locks", O_RDONLY | O_CREAT) ); - resource = (int*)malloc(sizeof(int)); - *resource = -1; - - /***** - * 3) Setup real-time parameters. - * In this example, we create a sporadic task that does not specify a - * target partition (and thus is intended to run under global scheduling). - * If this were to execute under a partitioned scheduler, it would be assigned - * to the first partition (since partitioning is performed offline). - */ - - CALL( init_litmus() ); - //CALL( sporadic_global(EXEC_COST, PERIOD) ); - CALL( sporadic_partitioned(EXEC_COST, PERIOD, 0) ); - - /* To specify a partition, use sporadic_partitioned(). - * Example: - * - * sporadic_partitioned(EXEC_COST, PERIOD, CPU); - * - * where CPU ranges from 0 to "Number of CPUs" - 1. - */ - - /***** - * 4) Transition to real-time mode. - */ - CALL( task_mode(LITMUS_RT_TASK) ); - - /* The task is now executing as a real-time task if the call didn't fail. - */ - - CALL(od_org = open_new_dgl_sem(fd, 0) ); - CALL(od_new = attach_dgl_sem(fd, 1, od_org) ); - - mask = (1<