Index: /experiments/DRMAA_tests/DRMAA_helloWorld/Makefile
===================================================================
--- /experiments/DRMAA_tests/DRMAA_helloWorld/Makefile	(revision 16)
+++ /experiments/DRMAA_tests/DRMAA_helloWorld/Makefile	(revision 16)
@@ -0,0 +1,7 @@
+hello : hello.c
+	gcc hello.c -o hello -ldrmaa -I/opt/sge/include/ -L/opt/sge/lib/lx26-amd64/ -Wl,-R/opt/sge/lib/lx26-amd64/
+
+.PHONY: clean
+
+clean :
+	rm hello
Index: /experiments/DRMAA_tests/DRMAA_helloWorld/hello.c
===================================================================
--- /experiments/DRMAA_tests/DRMAA_helloWorld/hello.c	(revision 16)
+++ /experiments/DRMAA_tests/DRMAA_helloWorld/hello.c	(revision 16)
@@ -0,0 +1,61 @@
+#include <stdio.h>
+#include <drmaa.h>
+
+int main(int argc, char **argv) {
+	char error[DRMAA_ERROR_STRING_BUFFER];
+	int errnum = 0;
+	drmaa_job_template_t *jt = NULL;
+
+	errnum = drmaa_init(NULL, error, DRMAA_ERROR_STRING_BUFFER);
+
+	if (errnum != DRMAA_ERRNO_SUCCESS) {
+		fprintf(stderr, "Could not initialize the DRMAA library: %s\n", error);
+		return 1;
+	}
+	
+	errnum = drmaa_allocate_job_template(&jt, error, DRMAA_ERROR_STRING_BUFFER);
+
+	if (errnum != DRMAA_ERRNO_SUCCESS) {
+		 fprintf(stderr, "Could not create job template: %s\n", error);
+	} else {
+		errnum = drmaa_set_attribute(jt, DRMAA_REMOTE_COMMAND, "/bin/sleep", error, DRMAA_ERROR_STRING_BUFFER);
+
+		if (errnum != DRMAA_ERRNO_SUCCESS) {
+			fprintf(stderr, "Could not set attribute \"%s\": %s\n", DRMAA_REMOTE_COMMAND, error);
+		} else {
+			const char *args[2] = {"5", NULL};
+
+			errnum = drmaa_set_vector_attribute(jt, DRMAA_V_ARGV, args, error, DRMAA_ERROR_STRING_BUFFER);
+		}
+
+		if (errnum != DRMAA_ERRNO_SUCCESS) {
+			fprintf(stderr, "Could not set attribute \"%s\": %s\n", DRMAA_REMOTE_COMMAND, error);
+		} else {
+			char jobid[DRMAA_JOBNAME_BUFFER];
+
+			errnum = drmaa_run_job(jobid, DRMAA_JOBNAME_BUFFER, jt, error, DRMAA_ERROR_STRING_BUFFER);
+
+			if (errnum != DRMAA_ERRNO_SUCCESS) {
+				fprintf(stderr, "Could not submit job: %s\n", error);
+			}
+			else {
+				printf("Your job has been submitted with id %s\n", jobid);
+			}
+		} /* else */
+
+		errnum = drmaa_delete_job_template(jt, error, DRMAA_ERROR_STRING_BUFFER);
+
+		if (errnum != DRMAA_ERRNO_SUCCESS) {
+			fprintf(stderr, "Could not delete job template: %s\n", error);
+		}
+	} /* else */
+
+	errnum = drmaa_exit(error, DRMAA_ERROR_STRING_BUFFER);
+
+	if (errnum != DRMAA_ERRNO_SUCCESS) {
+		fprintf(stderr, "Could not shut down the DRMAA library: %s\n", error);
+		return 1;
+	}
+
+	return 0;
+}
Index: /experiments/DRMAA_tests/DRMAA_args/args_helper.c
===================================================================
--- /experiments/DRMAA_tests/DRMAA_args/args_helper.c	(revision 16)
+++ /experiments/DRMAA_tests/DRMAA_args/args_helper.c	(revision 16)
@@ -0,0 +1,10 @@
+#include <stdlib.h>
+#include <stdio.h>
+
+int main(int argc,char *argv[])
+{
+	int i;
+	for (i = 1; i < argc;i++)
+		printf("%d: %s\n",i,argv[i]);
+	return 0;
+}
Index: /experiments/DRMAA_tests/DRMAA_args/args.c
===================================================================
--- /experiments/DRMAA_tests/DRMAA_args/args.c	(revision 16)
+++ /experiments/DRMAA_tests/DRMAA_args/args.c	(revision 16)
@@ -0,0 +1,201 @@
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <drmaa.h>
+
+#define JOB_CHUNK 1
+#define NBULKS 1
+
+static drmaa_job_template_t *create_job_template(const char *job_path, int seconds,
+int as_bulk_job);
+
+int main(int argc, char *argv[])
+{
+	char diagnosis[DRMAA_ERROR_STRING_BUFFER];
+	const char *all_jobids[NBULKS*JOB_CHUNK + JOB_CHUNK+1];
+	char jobid[100];
+	int drmaa_errno, i, pos = 0;
+	const char *job_path = NULL;
+	drmaa_job_template_t *jt = NULL;
+	
+	job_path = strdup("args_helper");
+	if (drmaa_init(NULL, diagnosis, sizeof(diagnosis)-1) != DRMAA_ERRNO_SUCCESS) 
+	{
+		fprintf(stderr, "drmaa_init() failed: %s\n", diagnosis);
+		return 1;
+	}
+
+	/*
+	* submit some bulk jobs
+	*/
+/*	if (!(jt = create_job_template(job_path, 5, 1))) 
+	{
+		fprintf(stderr, "create_job_template() failed\n");
+		return 1;
+	}
+	for (i=0; i<NBULKS; i++) 
+	{
+		drmaa_job_ids_t *jobids = NULL;
+		int j;
+		while ((drmaa_errno=drmaa_run_bulk_jobs(&jobids, jt, 1, JOB_CHUNK, 1, diagnosis,
+		sizeof(diagnosis)-1)) == DRMAA_ERRNO_DRM_COMMUNICATION_FAILURE)
+		{
+			fprintf(stderr, "drmaa_run_bulk_jobs() failed - retry: %s %s\n", diagnosis,
+			drmaa_strerror(drmaa_errno));
+			sleep(1);
+		}
+		
+		if (drmaa_errno != DRMAA_ERRNO_SUCCESS) 
+		{
+			fprintf(stderr, "drmaa_run_bulk_jobs() failed: %s %s\n", diagnosis,
+			drmaa_strerror(drmaa_errno));
+			return 1;
+		}
+		printf("submitted bulk job with jobids:\n");
+		for (j=0; j<JOB_CHUNK; j++) 
+		{
+			drmaa_get_next_job_id(jobids, jobid, sizeof(jobid)-1);
+			all_jobids[pos++] = strdup(jobid);
+			printf("\t \"%s\"\n", jobid);
+		}
+		drmaa_release_job_ids(jobids);
+	}
+	drmaa_delete_job_template(jt, NULL, 0); */
+	/*
+	* submit some sequential jobs
+	*/
+	if (!(jt = create_job_template(job_path, 1, 0))) 
+	{
+		fprintf(stderr, "create_sleeper_job_template() failed\n");
+		return 1;
+	}
+	
+	for (i=0; i<1; i++) 
+	{
+		while ((drmaa_errno=drmaa_run_job(jobid, sizeof(jobid)-1, jt, diagnosis,
+		sizeof(diagnosis)-1)) ==
+		DRMAA_ERRNO_DRM_COMMUNICATION_FAILURE)
+		{
+			fprintf(stderr, "drmaa_run_job() failed - retry: %s\n", diagnosis);
+			sleep(1);
+		}
+		
+		if (drmaa_errno != DRMAA_ERRNO_SUCCESS)
+		{
+			fprintf(stderr, "drmaa_run_job() failed: %s\n", diagnosis);
+			return 1;
+		}
+		
+		printf("\t \"%s\"\n", jobid);
+		all_jobids[pos++] = strdup(jobid);
+	}
+	/* set string array end mark */
+	all_jobids[pos] = NULL;
+	drmaa_delete_job_template(jt, NULL, 0);
+	/*
+	* synchronize with all jobs
+	*/
+	/*drmaa_errno = drmaa_synchronize(all_jobids, DRMAA_TIMEOUT_WAIT_FOREVER, 0, diagnosis,
+	sizeof(diagnosis)-1);
+	if (drmaa_errno != DRMAA_ERRNO_SUCCESS)
+	{
+		fprintf(stderr, 	"drmaa_synchronize(DRMAA_JOB_IDS_SESSION_ALL, dispose) failed: %s\n",	diagnosis);
+		return 1;
+	}
+	printf("synchronized with all jobs\n");
+*/
+	/*
+	* wait all those jobs
+	*/
+	for (pos=0; pos< 1; pos++) 
+	{
+		int stat;
+		int aborted, exited, exit_status, signaled;
+		printf("\nDrmaa_wait\n");
+		drmaa_errno = drmaa_wait(all_jobids[pos], jobid, sizeof(jobid)-1, &stat,DRMAA_TIMEOUT_WAIT_FOREVER, NULL, diagnosis, sizeof(diagnosis)-1);
+		printf("\nAfter drmaa_wait\n");
+		if (drmaa_errno != DRMAA_ERRNO_SUCCESS)
+		{
+			fprintf(stderr, "drmaa_wait(%s) failed: %s\n", all_jobids[pos], diagnosis);
+			return 1;
+		}
+		/*
+		* report how job finished
+		*/
+		drmaa_wifaborted(&aborted, stat, NULL, 0);
+		if (aborted) 
+		{
+			printf("job \"%s\" never ran\n", all_jobids[pos]);
+		}
+		else 
+		{
+			drmaa_wifexited(&exited, stat, NULL, 0);
+			if (exited)
+			{
+				drmaa_wexitstatus(&exit_status, stat, NULL, 0);
+				printf("job \"%s\" finished regularly with exit status %d\n",
+				all_jobids[pos], exit_status);
+			} 
+			else 
+			{
+				drmaa_wifsignaled(&signaled, stat, NULL, 0);
+				if (signaled) 
+				{
+					char termsig[DRMAA_SIGNAL_BUFFER+1];
+					drmaa_wtermsig(termsig, DRMAA_SIGNAL_BUFFER, stat, NULL, 0);
+					printf("job \"%s\" finished due to signal %s\n",
+					all_jobids[pos], termsig);
+				} 
+				else
+				{
+					printf("job \"%s\" finished with unclear conditions\n",
+					all_jobids[pos]);
+				}
+			}
+		}
+	}
+	
+	if (drmaa_exit(diagnosis, sizeof(diagnosis)-1) != DRMAA_ERRNO_SUCCESS)
+	{
+		fprintf(stderr, "drmaa_exit() failed: %s\n", diagnosis);
+		return 1;
+	}
+	return 0;
+}
+
+	static drmaa_job_template_t *create_job_template(const char *job_path, int seconds,	int as_bulk_job)
+	{
+		const char *job_argv[3];
+		drmaa_job_template_t *jt = NULL;
+		char buffer[100];
+		if (drmaa_allocate_job_template(&jt, NULL, 0)!=DRMAA_ERRNO_SUCCESS) 
+		{
+			return NULL;
+		}
+		/* run in users home directory */
+		drmaa_set_attribute(jt, DRMAA_WD, DRMAA_PLACEHOLDER_HD"/michal/experiments/DRMAA_tests/DRMAA_args", NULL, 0);
+		drmaa_set_attribute(jt, DRMAA_OUTPUT_PATH, ":"DRMAA_PLACEHOLDER_HD"/test_out", NULL , 0);
+		
+		
+		/* the job to be run */
+		drmaa_set_attribute(jt, DRMAA_REMOTE_COMMAND, job_path, NULL, 0);
+		/*drmaa_set_attribute(jt, DRMAA_JOB_CATEGORY, "default", NULL, 0); */
+		/* the job's arguments */
+		sprintf(buffer, "%d", seconds);
+		job_argv[0] = strdup("tabs dwaps trzyps");
+		job_argv[1] = strdup("jeden dwa");
+		job_argv[2] = NULL;
+		drmaa_set_vector_attribute(jt, DRMAA_V_ARGV, job_argv, NULL, 0);
+		/* join output/error file */
+		drmaa_set_attribute(jt, DRMAA_JOIN_FILES, "y", NULL, 0);
+		/* path for output */
+	/*	if (!as_bulk_job)
+		{
+			drmaa_set_attribute(jt, DRMAA_OUTPUT_PATH, ":"DRMAA_PLACEHOLDER_HD"/DRMAA_JOB",	NULL, 0);
+		} 
+		else
+		{
+			drmaa_set_attribute(jt, DRMAA_OUTPUT_PATH,":"DRMAA_PLACEHOLDER_HD"/DRMAA_JOB."DRMAA_PLACEHOLDER_INCR, NULL, 0);
+		}*/
+		return jt;
+	}
Index: /experiments/DRMAA_tests/DRMAA_Scalability/scalability.c
===================================================================
--- /experiments/DRMAA_tests/DRMAA_Scalability/scalability.c	(revision 16)
+++ /experiments/DRMAA_tests/DRMAA_Scalability/scalability.c	(revision 16)
@@ -0,0 +1,377 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <assert.h>
+#include <limits.h>
+#include <signal.h>
+#include <string.h>
+#include <unistd.h>
+#include <pthread.h>
+
+#include <drmaa.h>
+
+int SLEEP_TIME;
+int run;
+
+#define NTHREADS 4
+
+typedef struct{
+	int size;
+	int finished;
+	char **tab; 
+	pthread_mutex_t mutex;
+}vectorChar;
+
+vectorChar all_jobids;
+
+static drmaa_job_template_t *create_sleeper_job_template(int seconds)
+{
+	const char *job_argv[2];
+	drmaa_job_template_t *jt = NULL;
+	char buffer[100];
+	int ret = DRMAA_ERRNO_SUCCESS;
+
+	ret = drmaa_allocate_job_template(&jt, NULL, 0);
+	if (ret != DRMAA_ERRNO_SUCCESS) return NULL;
+	
+	ret = drmaa_set_attribute(jt, DRMAA_WD, DRMAA_PLACEHOLDER_HD, NULL, 0);
+	if (ret != DRMAA_ERRNO_SUCCESS) return NULL;
+
+	ret = drmaa_set_attribute(jt, DRMAA_REMOTE_COMMAND, "/bin/sleep", NULL, 0);
+	if (ret != DRMAA_ERRNO_SUCCESS) return NULL;
+
+	ret = drmaa_set_attribute(jt, DRMAA_OUTPUT_PATH, ":/dev/null",NULL, 0);
+	if (ret != DRMAA_ERRNO_SUCCESS) return NULL;
+	
+	sprintf(buffer, "%d", seconds);
+	job_argv[0] = buffer; 
+	job_argv[1] = NULL;
+	ret = drmaa_set_vector_attribute(jt, DRMAA_V_ARGV, job_argv, NULL, 0);
+	if (ret != DRMAA_ERRNO_SUCCESS) return NULL;
+
+	return jt;
+}
+
+
+static int do_submit(drmaa_job_template_t *jt)
+{
+	char diagnosis[1024];
+	char jobid[100];
+	int drmaa_errno = DRMAA_ERRNO_SUCCESS;
+	int error = DRMAA_ERRNO_SUCCESS;
+	int done;
+
+	done = 0;
+	while (!done) 
+	{
+		drmaa_errno = drmaa_run_job(jobid, sizeof(jobid)-1, jt, diagnosis, sizeof(diagnosis)-1);
+
+		if (drmaa_errno != DRMAA_ERRNO_SUCCESS) 
+		{
+			printf("failed submitting job (%s)\n", drmaa_strerror(drmaa_errno));
+		}
+
+		/* Only retry on "try again" error. */
+		if (drmaa_errno == DRMAA_ERRNO_TRY_LATER) 
+		{
+			printf("retry: %s\n", diagnosis);
+			sleep(1);
+		} else {
+			done = 1;
+			break; /* while */
+		}
+	}
+
+	if (drmaa_errno == DRMAA_ERRNO_SUCCESS) {
+		printf("Submitted job \"%s\"\n", jobid);
+	} else {
+		printf("Unable to submit job\n");
+	}
+	
+	pthread_mutex_lock(&all_jobids.mutex);
+	all_jobids.tab = realloc(all_jobids.tab,(all_jobids.size+1)*sizeof(char)*256); 
+	all_jobids.tab[all_jobids.size] = strdup(jobid);
+	all_jobids.size++;
+	pthread_mutex_unlock(&all_jobids.mutex);
+	
+	if (drmaa_errno != DRMAA_ERRNO_SUCCESS) {
+		/* If there is ever an error, we will return an error. */
+		error = drmaa_errno;
+	}
+
+	return error;
+}
+
+
+static void *create_job_thread (void *vp) {
+	int n;
+
+	if (vp != NULL) {
+		n = *(int *)vp;
+	}
+	else {
+		n = 1;
+	}
+
+	drmaa_job_template_t *jt = NULL;
+	int ret = DRMAA_ERRNO_SUCCESS;
+
+	if ((jt = create_sleeper_job_template(SLEEP_TIME)) == NULL)
+	{
+		fprintf(stderr, "create_sleeper_job_template() failed\n");
+		assert(0);
+	}
+
+	while(run)
+	{		
+		ret = do_submit(jt);
+		if(ret != DRMAA_ERRNO_SUCCESS)
+		{
+			fprintf(stderr,"submit failed()\n");
+			assert(0);
+		}
+
+		usleep(n*1000);
+	}
+	
+	drmaa_delete_job_template(jt, NULL, 0);
+	
+	return (void *)NULL;
+}
+
+static void *check_job_thread (void *vp)
+{
+	int n,pos,job_state;
+	char diagnosis[1024];
+	
+	if (vp != NULL) {
+		n = *(int *)vp;
+	}
+	else {
+		n = 1;
+	}
+
+	while(run)
+	{
+		pthread_mutex_lock(&all_jobids.mutex);
+		
+		for(pos = 0; pos<all_jobids.size; pos++)
+		{
+			if(all_jobids.tab[pos]!=NULL) 	/* if not ended */
+			{
+				if (drmaa_job_ps(all_jobids.tab[pos], &job_state, diagnosis, sizeof(diagnosis)-1)!=DRMAA_ERRNO_SUCCESS) 
+				{
+						fprintf(stderr, "drmaa_job_ps(\"%s\")) failed: %s\n", all_jobids.tab[pos], diagnosis);
+				}
+				printf("Job: %s - state: %d\n",all_jobids.tab[pos],job_state);
+			}	
+		}
+		
+		pthread_mutex_unlock(&all_jobids.mutex);
+		
+		sleep(n);
+	}
+	
+	return (void *)NULL;
+}
+
+static void *wait_thread (void *vp) 
+{
+	int n,i;
+	char jobid[256] = "";
+	int stat;
+	char diagnosis[1024];
+	int drmaa_errno = DRMAA_ERRNO_SUCCESS;
+	if (vp != NULL) {
+		n = *(int *)vp;
+	}
+	else {
+		n = 1;
+	}
+	pthread_mutex_lock(&all_jobids.mutex);
+	while(run || all_jobids.finished!=all_jobids.size)
+	{
+		pthread_mutex_unlock(&all_jobids.mutex);
+
+		drmaa_errno = drmaa_wait(DRMAA_JOB_IDS_SESSION_ANY, jobid, sizeof(jobid)-1, &stat,n, NULL, diagnosis, sizeof(diagnosis)-1);
+		if (drmaa_errno != DRMAA_ERRNO_SUCCESS && drmaa_errno != DRMAA_ERRNO_EXIT_TIMEOUT && drmaa_errno != DRMAA_ERRNO_INVALID_JOB)
+		{
+			fprintf(stderr, "drmaa_wait() failed: %s\n", diagnosis);
+			assert(0);
+		}
+
+		pthread_mutex_lock(&all_jobids.mutex);
+
+		for(i=0;i<all_jobids.size;i++)
+		{
+			if(all_jobids.tab[i] != NULL  && strcmp(all_jobids.tab[i],jobid) == 0)
+			{
+				free(all_jobids.tab[i]);
+				all_jobids.tab[i] = NULL;
+				all_jobids.finished++;
+				printf("Job %s ended. %d/%d\n",jobid,all_jobids.finished,all_jobids.size);
+				strcpy(jobid , "");
+				break;
+			}
+		}		
+	}
+	pthread_mutex_unlock(&all_jobids.mutex);
+	return (void *)NULL;
+}
+
+static void *kill_thread (void *vp) 
+{
+	int n,i,job_state;
+	char diagnosis[1024];
+	int drmaa_errno = DRMAA_ERRNO_SUCCESS;
+
+	if (vp != NULL) {
+		n = *(int *)vp;
+	}
+	else {
+		n = 1;
+	}
+
+	srand((unsigned)time(NULL));
+	
+	pthread_mutex_lock(&all_jobids.mutex);	
+	while(run || all_jobids.finished!=all_jobids.size)
+	{		
+		if(all_jobids.size>0)
+		{
+			i = rand()% all_jobids.size;
+
+			if(all_jobids.tab[i] != NULL)
+			{
+				if (drmaa_job_ps(all_jobids.tab[i], &job_state, diagnosis, sizeof(diagnosis)-1)!=DRMAA_ERRNO_SUCCESS) 
+				{
+						fprintf(stderr, "drmaa_job_ps(\"%s\")) failed: %s\n", all_jobids.tab[i], diagnosis);
+				}
+				else
+				{
+					if(job_state != DRMAA_PS_DONE && job_state != DRMAA_PS_FAILED)
+					{
+						drmaa_errno = drmaa_control(all_jobids.tab[i],DRMAA_CONTROL_TERMINATE, diagnosis,sizeof(diagnosis)-1);
+				
+						printf("Terminating %s\n",all_jobids.tab[i]);
+						if (drmaa_errno != DRMAA_ERRNO_SUCCESS && drmaa_errno != DRMAA_ERRNO_EXIT_TIMEOUT && drmaa_errno != DRMAA_ERRNO_INVALID_JOB)
+						{
+							fprintf(stderr, "drmaa_control() failed: %s\n", diagnosis);
+						}
+					}
+				}
+			}
+		}
+	
+		pthread_mutex_unlock(&all_jobids.mutex);
+		sleep(rand()% n);		
+		pthread_mutex_lock(&all_jobids.mutex);
+				
+	}
+	pthread_mutex_unlock(&all_jobids.mutex);
+	return (void *)NULL;
+}
+
+void catch_stop()
+{
+	printf("Caught ctrl+c\n");
+	run = 0;
+}
+
+int main(int argc, char* argv[])
+{
+	int i;
+	char diagnosis[DRMAA_ERROR_STRING_BUFFER];
+	int SUB_INT, POOL_INTERVAL,WAIT_INTERVAL,KILL_RANGE;
+	pthread_t submitter_threads[NTHREADS]; 
+	run = 1;
+	
+	if(argc < 6)
+	{
+		fprintf(stderr,"To less arguments\n");
+		return 1;
+	}
+	
+	printf("SUB_INT: %s msec\n",argv[1]);
+	printf("SLEEP_TIME: %s sec\n",argv[2]);
+	printf("POOL_INTERVAL: %s sec\n",argv[3]);
+	printf("WAIT_INTERVAL: %s sec\n",argv[4]);
+	printf("KILL_RANGE: %s sec\n",argv[5]);
+
+	printf("Stop by ctrl+z\n");
+
+	if(sscanf(argv[1],"%d",&SUB_INT) != 1)
+	{
+		fprintf(stderr,"Conversion of argument can't be done");
+		return 1;
+	}
+	
+	if(sscanf(argv[2],"%d",&SLEEP_TIME) != 1)
+	{
+		fprintf(stderr,"Conversion of argument can't be done");
+		return 1;
+	}
+	
+	if(sscanf(argv[3],"%d",&POOL_INTERVAL) != 1)
+	{
+		fprintf(stderr,"Conversion of argument can't be done");
+		return 1;
+	}
+	
+	if(sscanf(argv[4],"%d",&WAIT_INTERVAL) != 1)
+	{
+		fprintf(stderr,"Conversion of argument can't be done");
+		return 1;
+	}
+
+	if(sscanf(argv[5],"%d",&KILL_RANGE) != 1)
+	{
+		fprintf(stderr,"Conversion of argument can't be done");
+		return 1;
+	}
+	
+	all_jobids.size = 0;
+	all_jobids.tab = (char **)calloc(1,sizeof(char)*256);
+	pthread_mutex_init(&all_jobids.mutex,NULL);
+	
+	if (drmaa_init(NULL, diagnosis, sizeof(diagnosis)-1) != DRMAA_ERRNO_SUCCESS) 
+	{
+		fprintf(stderr, "drmaa_init() failed: %s\n", diagnosis);
+		return 1;
+	}
+		
+	signal(SIGINT,catch_stop);
+	
+	printf("Running create_job_thread\n");
+	pthread_create(&submitter_threads[0], NULL, create_job_thread, &SUB_INT);
+	
+	printf("Running check_job_thread\n");
+	pthread_create(&submitter_threads[1], NULL, check_job_thread, &POOL_INTERVAL);
+	
+	printf("Running wait_thread\n");
+	pthread_create(&submitter_threads[2], NULL, wait_thread, &WAIT_INTERVAL);
+	
+	printf("Running kill_thread\n");
+	pthread_create(&submitter_threads[3], NULL, kill_thread, &KILL_RANGE);
+
+	printf("Joining threads\n");	
+	for (i=0; i<NTHREADS; i++)
+		if (pthread_join(submitter_threads[i], NULL)) 
+			printf("pthread_join() returned != 0\n");
+		
+	while(all_jobids.size>0)
+	{
+		free(all_jobids.tab[all_jobids.size-1]);
+		all_jobids.size--;
+	}
+	free(all_jobids.tab);
+	
+	pthread_mutex_destroy(&all_jobids.mutex);
+	
+	if (drmaa_exit(diagnosis, sizeof(diagnosis)-1) != DRMAA_ERRNO_SUCCESS) 
+	{
+		fprintf(stderr, "drmaa_exit() failed: %s\n", diagnosis);
+		return 1;
+	}
+	printf("Successfully ended\n");
+	return 0;
+}
Index: /experiments/DRMAA_tests/DRMAA_Scalability/Makefile
===================================================================
--- /experiments/DRMAA_tests/DRMAA_Scalability/Makefile	(revision 16)
+++ /experiments/DRMAA_tests/DRMAA_Scalability/Makefile	(revision 16)
@@ -0,0 +1,9 @@
+scalability : scalability.c
+	gcc -Wall scalability.c -g -o scalability  -ldrmaa -I/opt/sge/include/ -L/opt/sge/lib/lx26-amd64/ -Wl,-R/opt/sge/lib/lx26-amd64/
+
+.PHONY: clean
+
+clean :
+	rm scalability
+
+	
Index: /experiments/DRMAA_tests/DRMAA_suspend/test.c
===================================================================
--- /experiments/DRMAA_tests/DRMAA_suspend/test.c	(revision 16)
+++ /experiments/DRMAA_tests/DRMAA_suspend/test.c	(revision 16)
@@ -0,0 +1,27 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+int main(int argc, char **argv) 
+{
+	int i = 0,w=1;
+	
+	if(argc<2)
+	{
+		fprintf(stderr,"N?\n");
+		return 1;
+	}
+	int fd;
+	int maxfd=sysconf(_SC_OPEN_MAX);
+	printf("jestesmy tu: %d",maxfd);
+	for(fd=1; fd<maxfd; fd++)
+		close(fd);
+		
+	sleep(1000);
+	for(i=2;i<=atoi(argv[1]);i++)
+		w*=i;
+		
+	printf("Silnia z %s to %d\n",argv[1],w);
+	
+	return 0;
+}
Index: /experiments/DRMAA_tests/DRMAA_suspend/suspend.c
===================================================================
--- /experiments/DRMAA_tests/DRMAA_suspend/suspend.c	(revision 16)
+++ /experiments/DRMAA_tests/DRMAA_suspend/suspend.c	(revision 16)
@@ -0,0 +1,216 @@
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <drmaa.h>
+
+#define JOB_CHUNK 1
+#define NBULKS 1
+
+static drmaa_job_template_t *create_job_template(const char *job_path, int seconds,
+int as_bulk_job);
+
+int main(int argc, char *argv[])
+{
+	char diagnosis[DRMAA_ERROR_STRING_BUFFER];
+	const char *all_jobids[NBULKS*JOB_CHUNK + JOB_CHUNK+1];
+	char jobid[100];
+	int drmaa_errno, i, pos = 0;
+	const char *job_path = NULL;
+	drmaa_job_template_t *jt = NULL;
+	
+	if (argc<2) 
+	{
+		fprintf(stderr, "usage: example <path-to-job>\n");
+		return 1;
+	}
+	
+	job_path = argv[1];
+	if (drmaa_init(NULL, diagnosis, sizeof(diagnosis)-1) != DRMAA_ERRNO_SUCCESS) 
+	{
+		fprintf(stderr, "drmaa_init() failed: %s\n", diagnosis);
+		return 1;
+	}
+
+	/*
+	* submit some bulk jobs
+	*/
+/*	if (!(jt = create_job_template(job_path, 5, 1))) 
+	{
+		fprintf(stderr, "create_job_template() failed\n");
+		return 1;
+	}
+	for (i=0; i<NBULKS; i++) 
+	{
+		drmaa_job_ids_t *jobids = NULL;
+		int j;
+		while ((drmaa_errno=drmaa_run_bulk_jobs(&jobids, jt, 1, JOB_CHUNK, 1, diagnosis,
+		sizeof(diagnosis)-1)) == DRMAA_ERRNO_DRM_COMMUNICATION_FAILURE)
+		{
+			fprintf(stderr, "drmaa_run_bulk_jobs() failed - retry: %s %s\n", diagnosis,
+			drmaa_strerror(drmaa_errno));
+			sleep(1);
+		}
+		
+		if (drmaa_errno != DRMAA_ERRNO_SUCCESS) 
+		{
+			fprintf(stderr, "drmaa_run_bulk_jobs() failed: %s %s\n", diagnosis,
+			drmaa_strerror(drmaa_errno));
+			return 1;
+		}
+		printf("submitted bulk job with jobids:\n");
+		for (j=0; j<JOB_CHUNK; j++) 
+		{
+			drmaa_get_next_job_id(jobids, jobid, sizeof(jobid)-1);
+			all_jobids[pos++] = strdup(jobid);
+			printf("\t \"%s\"\n", jobid);
+		}
+		drmaa_release_job_ids(jobids);
+	}
+	drmaa_delete_job_template(jt, NULL, 0); */
+	/*
+	* submit some sequential jobs
+	*/
+	if (!(jt = create_job_template(job_path, 1, 0))) 
+	{
+		fprintf(stderr, "create_sleeper_job_template() failed\n");
+		return 1;
+	}
+	
+	for (i=0; i<1; i++) 
+	{
+		while ((drmaa_errno=drmaa_run_job(jobid, sizeof(jobid)-1, jt, diagnosis,
+		sizeof(diagnosis)-1)) ==
+		DRMAA_ERRNO_DRM_COMMUNICATION_FAILURE)
+		{
+			fprintf(stderr, "drmaa_run_job() failed - retry: %s\n", diagnosis);
+			sleep(1);
+		}
+		
+		if (drmaa_errno != DRMAA_ERRNO_SUCCESS)
+		{
+			fprintf(stderr, "drmaa_run_job() failed: %s\n", diagnosis);
+			return 1;
+		}
+		
+		printf("\t \"%s\"\n", jobid);
+		all_jobids[pos++] = strdup(jobid);
+	}
+	/* set string array end mark */
+	all_jobids[pos] = NULL;
+	drmaa_delete_job_template(jt, NULL, 0);
+	sleep(2);
+	drmaa_control(jobid, DRMAA_CONTROL_SUSPEND,diagnosis, sizeof(diagnosis)-1);
+	/*
+	* synchronize with all jobs
+	*/
+	/*drmaa_errno = drmaa_synchronize(all_jobids, DRMAA_TIMEOUT_WAIT_FOREVER, 0, diagnosis,
+	sizeof(diagnosis)-1);
+	if (drmaa_errno != DRMAA_ERRNO_SUCCESS)
+	{
+		fprintf(stderr, 	"drmaa_synchronize(DRMAA_JOB_IDS_SESSION_ALL, dispose) failed: %s\n",	diagnosis);
+		return 1;
+	}
+	printf("synchronized with all jobs\n");
+*/
+	/*
+	* wait all those jobs
+	*/
+	for (pos=0; pos< 1; pos++) 
+	{
+		int stat;
+		int aborted, exited, exit_status, signaled;
+		printf("\nDrmaa_wait\n");
+		drmaa_errno = drmaa_wait(all_jobids[pos], jobid, sizeof(jobid)-1, &stat,DRMAA_TIMEOUT_WAIT_FOREVER, NULL, diagnosis, sizeof(diagnosis)-1);
+		printf("\nAfter drmaa_wait\n");
+		if (drmaa_errno != DRMAA_ERRNO_SUCCESS)
+		{
+			fprintf(stderr, "drmaa_wait(%s) failed: %s\n", all_jobids[pos], diagnosis);
+			return 1;
+		}
+		/*
+		* report how job finished
+		*/
+		drmaa_wifaborted(&aborted, stat, NULL, 0);
+		if (aborted) 
+		{
+			printf("job \"%s\" never ran\n", all_jobids[pos]);
+		}
+		else 
+		{
+			drmaa_wifexited(&exited, stat, NULL, 0);
+			if (exited)
+			{
+				drmaa_wexitstatus(&exit_status, stat, NULL, 0);
+				printf("job \"%s\" finished regularly with exit status %d\n",
+				all_jobids[pos], exit_status);
+			} 
+			else 
+			{
+				drmaa_wifsignaled(&signaled, stat, NULL, 0);
+				if (signaled) 
+				{
+					char termsig[DRMAA_SIGNAL_BUFFER+1];
+					drmaa_wtermsig(termsig, DRMAA_SIGNAL_BUFFER, stat, NULL, 0);
+					printf("job \"%s\" finished due to signal %s\n",
+					all_jobids[pos], termsig);
+				} 
+				else
+				{
+					printf("job \"%s\" finished with unclear conditions\n",
+					all_jobids[pos]);
+				}
+			}
+		}
+	}
+	
+	if (drmaa_exit(diagnosis, sizeof(diagnosis)-1) != DRMAA_ERRNO_SUCCESS)
+	{
+		fprintf(stderr, "drmaa_exit() failed: %s\n", diagnosis);
+		return 1;
+	}
+	return 0;
+}
+
+	static drmaa_job_template_t *create_job_template(const char *job_path, int seconds,	int as_bulk_job)
+	{
+		const char *job_argv[2];
+		drmaa_job_template_t *jt = NULL;
+		char buffer[100];
+		if (drmaa_allocate_job_template(&jt, NULL, 0)!=DRMAA_ERRNO_SUCCESS) 
+		{
+			return NULL;
+		}
+		/* run in users home directory */
+		drmaa_set_attribute(jt, DRMAA_WD, DRMAA_PLACEHOLDER_HD"/michal/experiments/DRMAA_tests/DRMAA_suspend", NULL, 0);
+
+		/**/
+
+		
+		drmaa_set_attribute(jt, DRMAA_NATIVE_SPECIFICATION, "@restart = yes", NULL, 0);
+
+		drmaa_set_attribute(jt, DRMAA_WCT_SLIMIT, "5:00", NULL, 0);
+
+		/**/
+		
+		
+		/* the job to be run */
+		drmaa_set_attribute(jt, DRMAA_REMOTE_COMMAND, job_path, NULL, 0);
+
+		/* the job's arguments */
+		sprintf(buffer, "%d", seconds);
+		job_argv[0] = buffer;
+		job_argv[1] = NULL;
+		drmaa_set_vector_attribute(jt, DRMAA_V_ARGV, job_argv, NULL, 0);
+		/* join output/error file */
+		drmaa_set_attribute(jt, DRMAA_JOIN_FILES, "y", NULL, 0);
+		/* path for output */
+		if (!as_bulk_job)
+		{
+			drmaa_set_attribute(jt, DRMAA_OUTPUT_PATH, ":"DRMAA_PLACEHOLDER_HD"/DRMAA_JOB",	NULL, 0);
+		} 
+		else
+		{
+			drmaa_set_attribute(jt, DRMAA_OUTPUT_PATH,":"DRMAA_PLACEHOLDER_HD"/DRMAA_JOB."DRMAA_PLACEHOLDER_INCR, NULL, 0);
+		}
+		return jt;
+	}
Index: /experiments/DRMAA_tests/DRMAA_wait/wait.c
===================================================================
--- /experiments/DRMAA_tests/DRMAA_wait/wait.c	(revision 16)
+++ /experiments/DRMAA_tests/DRMAA_wait/wait.c	(revision 16)
@@ -0,0 +1,219 @@
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <drmaa.h>
+
+#define JOB_CHUNK 1
+#define NBULKS 1
+
+static drmaa_job_template_t *create_job_template(const char *job_path, int seconds,
+int as_bulk_job);
+
+int main(int argc, char *argv[])
+{
+	char diagnosis[DRMAA_ERROR_STRING_BUFFER];
+	const char *all_jobids[NBULKS*JOB_CHUNK + JOB_CHUNK+1];
+	char jobid[100];
+	int drmaa_errno, i, pos = 0;
+	const char *job_path = NULL;
+	drmaa_job_template_t *jt = NULL;
+	
+	if (argc<2) 
+	{
+		fprintf(stderr, "usage: example <path-to-job>\n");
+		return 1;
+	}
+	
+	job_path = argv[1];
+	if (drmaa_init(NULL, diagnosis, sizeof(diagnosis)-1) != DRMAA_ERRNO_SUCCESS) 
+	{
+		fprintf(stderr, "drmaa_init() failed: %s\n", diagnosis);
+		return 1;
+	}
+
+	/*
+	* submit some bulk jobs
+	*/
+/*	if (!(jt = create_job_template(job_path, 5, 1))) 
+	{
+		fprintf(stderr, "create_job_template() failed\n");
+		return 1;
+	}
+	for (i=0; i<NBULKS; i++) 
+	{
+		drmaa_job_ids_t *jobids = NULL;
+		int j;
+		while ((drmaa_errno=drmaa_run_bulk_jobs(&jobids, jt, 1, JOB_CHUNK, 1, diagnosis,
+		sizeof(diagnosis)-1)) == DRMAA_ERRNO_DRM_COMMUNICATION_FAILURE)
+		{
+			fprintf(stderr, "drmaa_run_bulk_jobs() failed - retry: %s %s\n", diagnosis,
+			drmaa_strerror(drmaa_errno));
+			sleep(1);
+		}
+		
+		if (drmaa_errno != DRMAA_ERRNO_SUCCESS) 
+		{
+			fprintf(stderr, "drmaa_run_bulk_jobs() failed: %s %s\n", diagnosis,
+			drmaa_strerror(drmaa_errno));
+			return 1;
+		}
+		printf("submitted bulk job with jobids:\n");
+		for (j=0; j<JOB_CHUNK; j++) 
+		{
+			drmaa_get_next_job_id(jobids, jobid, sizeof(jobid)-1);
+			all_jobids[pos++] = strdup(jobid);
+			printf("\t \"%s\"\n", jobid);
+		}
+		drmaa_release_job_ids(jobids);
+	}
+	drmaa_delete_job_template(jt, NULL, 0); */
+	/*
+	* submit some sequential jobs
+	*/
+	if (!(jt = create_job_template(job_path, 1, 0))) 
+	{
+		fprintf(stderr, "create_sleeper_job_template() failed\n");
+		return 1;
+	}
+	
+	for (i=0; i<1; i++) 
+	{
+		while ((drmaa_errno=drmaa_run_job(jobid, sizeof(jobid)-1, jt, diagnosis,
+		sizeof(diagnosis)-1)) ==
+		DRMAA_ERRNO_DRM_COMMUNICATION_FAILURE)
+		{
+			fprintf(stderr, "drmaa_run_job() failed - retry: %s\n", diagnosis);
+			sleep(1);
+		}
+		
+		if (drmaa_errno != DRMAA_ERRNO_SUCCESS)
+		{
+			fprintf(stderr, "drmaa_run_job() failed: %s\n", diagnosis);
+			return 1;
+		}
+		
+		printf("\t \"%s\"\n", jobid);
+		all_jobids[pos++] = strdup(jobid);
+	}
+	/* set string array end mark */
+	all_jobids[pos] = NULL;
+	drmaa_delete_job_template(jt, NULL, 0);
+	/*
+	* synchronize with all jobs
+	*/
+	/*drmaa_errno = drmaa_synchronize(all_jobids, DRMAA_TIMEOUT_WAIT_FOREVER, 0, diagnosis,
+	sizeof(diagnosis)-1);
+	if (drmaa_errno != DRMAA_ERRNO_SUCCESS)
+	{
+		fprintf(stderr, 	"drmaa_synchronize(DRMAA_JOB_IDS_SESSION_ALL, dispose) failed: %s\n",	diagnosis);
+		return 1;
+	}
+	printf("synchronized with all jobs\n");
+*/
+	/*
+	* wait all those jobs
+	*/
+	for (pos=0; pos< 1; pos++) 
+	{
+		int stat;
+		int aborted, exited, exit_status, signaled;
+		printf("\nDrmaa_wait\n");
+		drmaa_errno = drmaa_wait(all_jobids[pos], jobid, sizeof(jobid)-1, &stat,DRMAA_TIMEOUT_WAIT_FOREVER, NULL, diagnosis, sizeof(diagnosis)-1);
+		printf("\nAfter drmaa_wait\n");
+		if (drmaa_errno != DRMAA_ERRNO_SUCCESS)
+		{
+			fprintf(stderr, "drmaa_wait(%s) failed: %s\n", all_jobids[pos], diagnosis);
+			return 1;
+		}
+		/*
+		* report how job finished
+		*/
+		drmaa_wifaborted(&aborted, stat, NULL, 0);
+		if (aborted) 
+		{
+			printf("job \"%s\" never ran\n", all_jobids[pos]);
+		}
+		else 
+		{
+			drmaa_wifexited(&exited, stat, NULL, 0);
+			if (exited)
+			{
+				drmaa_wexitstatus(&exit_status, stat, NULL, 0);
+				printf("job \"%s\" finished regularly with exit status %d\n",
+				all_jobids[pos], exit_status);
+			} 
+			else 
+			{
+				drmaa_wifsignaled(&signaled, stat, NULL, 0);
+				if (signaled) 
+				{
+					char termsig[DRMAA_SIGNAL_BUFFER+1];
+					drmaa_wtermsig(termsig, DRMAA_SIGNAL_BUFFER, stat, NULL, 0);
+					printf("job \"%s\" finished due to signal %s\n",
+					all_jobids[pos], termsig);
+				} 
+				else
+				{
+					printf("job \"%s\" finished with unclear conditions\n",
+					all_jobids[pos]);
+				}
+			}
+		}
+	}
+	
+	if (drmaa_exit(diagnosis, sizeof(diagnosis)-1) != DRMAA_ERRNO_SUCCESS)
+	{
+		fprintf(stderr, "drmaa_exit() failed: %s\n", diagnosis);
+		return 1;
+	}
+	return 0;
+}
+
+	static drmaa_job_template_t *create_job_template(const char *job_path, int seconds,	int as_bulk_job)
+	{
+		const char *job_argv[2];
+		drmaa_job_template_t *jt = NULL;
+		char buffer[100];
+		if (drmaa_allocate_job_template(&jt, NULL, 0)!=DRMAA_ERRNO_SUCCESS) 
+		{
+			return NULL;
+		}
+		/* run in users home directory */
+		drmaa_set_attribute(jt, DRMAA_WD, DRMAA_PLACEHOLDER_HD, NULL, 0);
+
+		/**/
+		drmaa_set_attribute(jt, DRMAA_BLOCK_EMAIL, DRMAA_PLACEHOLDER_HD, NULL, 0);
+		/*drmaa_set_attribute(jt, DRMAA_JS_STATE, DRMAA_PS_USER_ON_HOLD, NULL, 0);*/
+		drmaa_set_attribute(jt, DRMAA_JOB_NAME, "moja_nazwa", NULL, 0);
+		/*drmaa_set_attribute(jt, DRMAA_INPUT_PATH, "", NULL, 0);*/
+		drmaa_set_attribute(jt, DRMAA_NATIVE_SPECIFICATION, "@checkpoint = yes @restart = yes @wall_clock_limit = 00:10:00", NULL, 0);
+		/*drmaa_set_attribute(jt, DRMAA_V_ENV, DRMAA_PLACEHOLDER_HD, NULL, 0);*/
+		drmaa_set_attribute(jt, DRMAA_V_EMAIL, "m@m.com", NULL, 0);
+		drmaa_set_attribute(jt, DRMAA_BLOCK_EMAIL, 0, NULL, 0);
+		/*drmaa_set_attribute(jt, DRMAA_START_TIME, "10/05/17 12:00:12 +01:00", NULL, 0);*/
+		/*drmaa_set_attribute(jt, DRMAA_WCT_SLIMIT, "5:00", NULL, 0);
+		drmaa_set_attribute(jt, DRMAA_WCT_HLIMIT, "4:00", NULL, 0);*/
+		/**/
+		
+		
+		/* the job to be run */
+		drmaa_set_attribute(jt, DRMAA_REMOTE_COMMAND, job_path, NULL, 0);
+		/*drmaa_set_attribute(jt, DRMAA_JOB_CATEGORY, "default", NULL, 0); */
+		/* the job's arguments */
+		sprintf(buffer, "%d", seconds);
+		job_argv[0] = buffer;
+		job_argv[1] = NULL;
+		drmaa_set_vector_attribute(jt, DRMAA_V_ARGV, job_argv, NULL, 0);
+		/* join output/error file */
+		drmaa_set_attribute(jt, DRMAA_JOIN_FILES, "y", NULL, 0);
+		/* path for output */
+		if (!as_bulk_job)
+		{
+			drmaa_set_attribute(jt, DRMAA_OUTPUT_PATH, ":"DRMAA_PLACEHOLDER_HD"/DRMAA_JOB",	NULL, 0);
+		} 
+		else
+		{
+			drmaa_set_attribute(jt, DRMAA_OUTPUT_PATH,":"DRMAA_PLACEHOLDER_HD"/DRMAA_JOB."DRMAA_PLACEHOLDER_INCR, NULL, 0);
+		}
+		return jt;
+	}
Index: /experiments/DRMAA_tests/DRMAA_wait/Makefile
===================================================================
--- /experiments/DRMAA_tests/DRMAA_wait/Makefile	(revision 16)
+++ /experiments/DRMAA_tests/DRMAA_wait/Makefile	(revision 16)
@@ -0,0 +1,7 @@
+hello : wait.c
+	gcc wait.c -g -o wait  -I/work/default/mamon/drmaa/include -L/work/default/mamon/drmaa/lib  -ldrmaa 
+
+.PHONY: clean
+
+clean :
+	rm wait
Index: /experiments/DRMAA_tests/DRMAA_test_5_7/Makefile
===================================================================
--- /experiments/DRMAA_tests/DRMAA_test_5_7/Makefile	(revision 16)
+++ /experiments/DRMAA_tests/DRMAA_test_5_7/Makefile	(revision 16)
@@ -0,0 +1,7 @@
+test : test.c
+	gcc test.c -g -o test  -I/work/default/mamon/drmaa/include -L/work/default/mamon/drmaa/lib  -ldrmaa 
+
+.PHONY: clean
+
+clean :
+	rm test
Index: /experiments/DRMAA_tests/DRMAA_test_5_7/test.c
===================================================================
--- /experiments/DRMAA_tests/DRMAA_test_5_7/test.c	(revision 16)
+++ /experiments/DRMAA_tests/DRMAA_test_5_7/test.c	(revision 16)
@@ -0,0 +1,48 @@
+#include <stdio.h>
+#include <drmaa.h>
+
+#define DRMAA_DRMAA_IMPL_BUFFER 1024
+
+void test()
+{
+	char contact[DRMAA_ERROR_STRING_BUFFER];
+	char error[DRMAA_ERROR_STRING_BUFFER];
+	char drm_system[DRMAA_DRMAA_IMPL_BUFFER];
+	char drmaa_impl[DRMAA_DRMAA_IMPL_BUFFER];
+	
+	int errno;
+	
+	unsigned int major;
+	unsigned int minor;
+	
+	errno = drmaa_get_contact(contact, DRMAA_CONTACT_BUFFER, error, DRMAA_ERROR_STRING_BUFFER);
+	printf("Contact: %s\n",contact);
+	printf("Error: %s\n",error);
+	printf("Errno: %d\n",errno);
+	
+	errno = drmaa_version(&major, &minor,error, DRMAA_ERROR_STRING_BUFFER);
+	printf("Major: %d\n",major);
+	printf("Minor: %d\n",minor);
+	printf("Error: %s\n",error);
+	printf("Errno: %d\n",errno);
+	
+	errno = drmaa_get_DRM_system(drm_system,DRMAA_DRMAA_IMPL_BUFFER,error,DRMAA_ERROR_STRING_BUFFER);
+	printf("System: %s\n",drm_system);
+	printf("Error: %s\n",error);
+	printf("Errno: %d\n",errno);
+	
+	errno = drmaa_get_DRMAA_implementation(drmaa_impl,DRMAA_DRMAA_IMPL_BUFFER,error,DRMAA_ERROR_STRING_BUFFER);
+	printf("Implementation: %s\n",drmaa_impl);
+	printf("Error: %s\n",error);
+	printf("Errno: %d\n",errno);
+}
+
+int main(int argc, char **argv) {
+    char error[DRMAA_ERROR_STRING_BUFFER];
+	test();
+	drmaa_init(NULL, error, sizeof(DRMAA_ERROR_STRING_BUFFER)-1);
+	printf("Init-------------------\n");
+	test();
+	drmaa_exit(error, DRMAA_ERROR_STRING_BUFFER);
+	return 0;
+}
Index: /experiments/DRMAA_tests/DRMAA_C_Bindings_Example/Makefile
===================================================================
--- /experiments/DRMAA_tests/DRMAA_C_Bindings_Example/Makefile	(revision 16)
+++ /experiments/DRMAA_tests/DRMAA_C_Bindings_Example/Makefile	(revision 16)
@@ -0,0 +1,7 @@
+hello : ex.c
+	gcc ex.c -g -o ex  -I/home/mamon/drmaa/include -L/home/mamon/drmaa/lib  -ldrmaa 
+
+.PHONY: clean
+
+clean :
+	rm ex
Index: /experiments/DRMAA_tests/DRMAA_C_Bindings_Example/ex.c
===================================================================
--- /experiments/DRMAA_tests/DRMAA_C_Bindings_Example/ex.c	(revision 16)
+++ /experiments/DRMAA_tests/DRMAA_C_Bindings_Example/ex.c	(revision 16)
@@ -0,0 +1,202 @@
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <drmaa.h>
+
+#define JOB_CHUNK 8
+#define NBULKS 1
+
+static drmaa_job_template_t *create_job_template(const char *job_path, int seconds,
+int as_bulk_job);
+
+int main(int argc, char *argv[])
+{
+	char diagnosis[DRMAA_ERROR_STRING_BUFFER];
+	const char *all_jobids[NBULKS*JOB_CHUNK + JOB_CHUNK+1];
+	char jobid[100];
+	int drmaa_errno, i, pos = 0;
+	const char *job_path = NULL;
+	drmaa_job_template_t *jt = NULL;
+	
+	if (argc<2) 
+	{
+		fprintf(stderr, "usage: example <path-to-job>\n");
+		return 1;
+	}
+	
+	job_path = argv[1];
+	if (drmaa_init(NULL, diagnosis, sizeof(diagnosis)-1) != DRMAA_ERRNO_SUCCESS) 
+	{
+		fprintf(stderr, "drmaa_init() failed: %s\n", diagnosis);
+		return 1;
+	}
+
+	/*
+	* submit some bulk jobs
+	*/
+	if (!(jt = create_job_template(job_path, 5, 1))) 
+	{
+		fprintf(stderr, "create_job_template() failed\n");
+		return 1;
+	}
+	for (i=0; i<NBULKS; i++) 
+	{
+		drmaa_job_ids_t *jobids = NULL;
+		int j;
+		while ((drmaa_errno=drmaa_run_bulk_jobs(&jobids, jt, 2, 8, 3, diagnosis,
+		sizeof(diagnosis)-1)) == DRMAA_ERRNO_DRM_COMMUNICATION_FAILURE)
+		{
+			fprintf(stderr, "drmaa_run_bulk_jobs() failed - retry: %s %s\n", diagnosis,
+			drmaa_strerror(drmaa_errno));
+			sleep(1);
+		}
+		
+		if (drmaa_errno != DRMAA_ERRNO_SUCCESS) 
+		{
+			fprintf(stderr, "drmaa_run_bulk_jobs() failed: %s %s\n", diagnosis,
+			drmaa_strerror(drmaa_errno));
+			return 1;
+		}
+		printf("submitted bulk job with jobids:\n");
+		for (j=0; j<3; j++) 
+		{
+			drmaa_get_next_job_id(jobids, jobid, sizeof(jobid)-1);
+			all_jobids[pos++] = strdup(jobid);
+			printf("\t \"%s\"\n", jobid);
+		}
+		drmaa_release_job_ids(jobids);
+	}
+	drmaa_delete_job_template(jt, NULL, 0);
+	/*
+	* submit some sequential jobs
+	*/
+	if (!(jt = create_job_template(job_path, 5, 0))) 
+	{
+		fprintf(stderr, "create_sleeper_job_template() failed\n");
+		return 1;
+	}
+	
+	for (i=0; i<3; i++) 
+	{
+		while ((drmaa_errno=drmaa_run_job(jobid, sizeof(jobid)-1, jt, diagnosis,
+		sizeof(diagnosis)-1)) ==
+		DRMAA_ERRNO_DRM_COMMUNICATION_FAILURE)
+		{
+			fprintf(stderr, "drmaa_run_job() failed - retry: %s\n", diagnosis);
+			sleep(1);
+		}
+		
+		if (drmaa_errno != DRMAA_ERRNO_SUCCESS)
+		{
+			fprintf(stderr, "drmaa_run_job() failed: %s\n", diagnosis);
+			return 1;
+		}
+		
+		printf("\t \"%s\"\n", jobid);
+		all_jobids[pos++] = strdup(jobid);
+	}
+	/* set string array end mark */
+	/*all_jobids[pos] = NULL;
+	drmaa_delete_job_template(jt, NULL, 0);*/
+	/*
+	* synchronize with all jobs
+	*/
+	drmaa_errno = drmaa_synchronize(all_jobids, DRMAA_TIMEOUT_WAIT_FOREVER, 0, diagnosis,
+	sizeof(diagnosis)-1);
+	if (drmaa_errno != DRMAA_ERRNO_SUCCESS)
+	{
+		fprintf(stderr, 	"drmaa_synchronize(DRMAA_JOB_IDS_SESSION_ALL, dispose) failed: %s\n",	diagnosis);
+		return 1;
+	}
+	printf("synchronized with all jobs\n");
+
+	/*
+	* wait all those jobs
+	*/
+	for (pos=0; pos<6; pos++) 
+	{
+		int stat;
+		int aborted, exited, exit_status, signaled;
+		drmaa_errno = drmaa_wait(all_jobids[pos], jobid, sizeof(jobid)-1, &stat,DRMAA_TIMEOUT_WAIT_FOREVER, NULL, diagnosis, sizeof(diagnosis)-1);
+		if (drmaa_errno != DRMAA_ERRNO_SUCCESS)
+		{
+			fprintf(stderr, "drmaa_wait(%s) failed: %s\n", all_jobids[pos], diagnosis);
+			return 1;
+		}
+		/*
+		* report how job finished
+		*/
+		drmaa_wifaborted(&aborted, stat, NULL, 0);
+		if (aborted) 
+		{
+			printf("job \"%s\" never ran\n", all_jobids[pos]);
+		}
+		else 
+		{
+			drmaa_wifexited(&exited, stat, NULL, 0);
+			if (exited)
+			{
+				drmaa_wexitstatus(&exit_status, stat, NULL, 0);
+				printf("job \"%s\" finished regularly with exit status %d\n",
+				all_jobids[pos], exit_status);
+			} 
+			else 
+			{
+				drmaa_wifsignaled(&signaled, stat, NULL, 0);
+				if (signaled) 
+				{
+					char termsig[DRMAA_SIGNAL_BUFFER+1];
+					drmaa_wtermsig(termsig, DRMAA_SIGNAL_BUFFER, stat, NULL, 0);
+					printf("job \"%s\" finished due to signal %s\n",
+					all_jobids[pos], termsig);
+				} 
+				else
+				{
+					printf("job \"%s\" finished with unclear conditions\n",
+					all_jobids[pos]);
+				}
+			}
+		}
+	}
+	
+	if (drmaa_exit(diagnosis, sizeof(diagnosis)-1) != DRMAA_ERRNO_SUCCESS)
+	{
+		fprintf(stderr, "drmaa_exit() failed: %s\n", diagnosis);
+		return 1;
+	}
+	return 0;
+}
+
+	static drmaa_job_template_t *create_job_template(const char *job_path, int seconds,	int as_bulk_job)
+	{
+		const char *job_argv[2];
+		drmaa_job_template_t *jt = NULL;
+		char buffer[100];
+		if (drmaa_allocate_job_template(&jt, NULL, 0)!=DRMAA_ERRNO_SUCCESS) 
+		{
+			return NULL;
+		}
+		/* run in users home directory */
+		drmaa_set_attribute(jt, DRMAA_WD, DRMAA_PLACEHOLDER_HD, NULL, 0);
+
+		/* the job to be run */
+		drmaa_set_attribute(jt, DRMAA_REMOTE_COMMAND, job_path, NULL, 0);
+		/* the job's arguments */
+		sprintf(buffer, "%d", seconds);
+		job_argv[0] = buffer;
+		job_argv[1] = NULL;
+		drmaa_set_vector_attribute(jt, DRMAA_V_ARGV, job_argv, NULL, 0);
+		drmaa_set_attribute(jt, DRMAA_NATIVE_SPECIFICATION, "@core_limit = 100mb @comment = this is my very first job @class = workq", NULL, 0);
+		/* join output/error file */
+		drmaa_set_attribute(jt, DRMAA_JOIN_FILES, "y", NULL, 0);
+		/* path for output */
+		if (!as_bulk_job)
+		{
+			drmaa_set_attribute(jt, DRMAA_OUTPUT_PATH, ":"DRMAA_PLACEHOLDER_HD"/DRMAA_JOB",	NULL, 0);
+		} 
+		else
+		{
+			drmaa_set_attribute(jt, DRMAA_OUTPUT_PATH,":"DRMAA_PLACEHOLDER_HD"/DRMAA_JOB."DRMAA_PLACEHOLDER_INCR, NULL, 0);
+		}
+		return jt;
+	}
Index: /experiments/DRMAA_tests/Join_test/Makefile
===================================================================
--- /experiments/DRMAA_tests/Join_test/Makefile	(revision 16)
+++ /experiments/DRMAA_tests/Join_test/Makefile	(revision 16)
@@ -0,0 +1,7 @@
+a : a.c
+	gcc a.c -o a -ldrmaa -I/opt/sge/include/ -L/opt/sge/lib/lx26-amd64/ -Wl,-R/opt/sge/lib/lx26-amd64/
+
+.PHONY: clean
+
+clean :
+	rm a
Index: /experiments/DRMAA_tests/Join_test/a.c
===================================================================
--- /experiments/DRMAA_tests/Join_test/a.c	(revision 16)
+++ /experiments/DRMAA_tests/Join_test/a.c	(revision 16)
@@ -0,0 +1,8 @@
+#include <stdlib.h>
+#include <drmaa.h>
+
+int main(int argc, char *argv[])
+{
+
+	return 0;
+}
Index: /experiments/bulk_parse/bulk_parse.c
===================================================================
--- /experiments/bulk_parse/bulk_parse.c	(revision 16)
+++ /experiments/bulk_parse/bulk_parse.c	(revision 16)
@@ -0,0 +1,11 @@
+#include <stdlib.h>
+#include <sys/wait.h>
+#include <stdio.h>
+
+int main(int argc, char *argv[])
+{
+	int i;
+	for(i = 0;i<100;i++)
+		printf("i: %d, wt: %d, m: %d\n",i,WEXITSTATUS(i), (i >> 8)&0xff);
+	return 0;
+}
Index: /experiments/bulk_parse/Makefile
===================================================================
--- /experiments/bulk_parse/Makefile	(revision 16)
+++ /experiments/bulk_parse/Makefile	(revision 16)
@@ -0,0 +1,7 @@
+bulk_parse  : bulk_parse.c
+	gcc -Wall bulk_parse.c -o bulk_parse 
+
+.PHONY: clean
+
+clean :
+	rm bulk_parse 
Index: /experiments/checkpoint/test.c
===================================================================
--- /experiments/checkpoint/test.c	(revision 16)
+++ /experiments/checkpoint/test.c	(revision 16)
@@ -0,0 +1,27 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+int main(int argc, char **argv) 
+{
+	int i = 0,w=1;
+	
+	if(argc<2)
+	{
+		fprintf(stderr,"N?\n");
+		return 1;
+	}
+	int fd;
+	int maxfd=sysconf(_SC_OPEN_MAX);
+	printf("jestesmy tu: %d",maxfd);
+	for(fd=1; fd<maxfd; fd++)
+		close(fd);
+		
+	sleep(1000);
+	for(i=2;i<=atoi(argv[1]);i++)
+		w*=i;
+		
+	printf("Silnia z %s to %d\n",argv[1],w);
+	
+	return 0;
+}
Index: /experiments/checkpoint/prog.cmd
===================================================================
--- /experiments/checkpoint/prog.cmd	(revision 16)
+++ /experiments/checkpoint/prog.cmd	(revision 16)
@@ -0,0 +1,15 @@
+#   The name of this job command file is file.cmd.
+#   The input file is longjob.in1 and the error file is
+#   longjob.err1. The queue statement marks the end of
+#   the job step.
+# @ initialdir = /home/mamon/michal/experiments/checkpoint
+# @ executable = /home/mamon/michal/experiments/checkpoint/test
+# @ arguments = 20
+# @ output = test.out
+# @ error = test.err
+# @ checkpoint = yes
+#  restart_on_same_nodes = yes
+#  restart_from_ckpt = yes
+#  ckpt_file = /home/mamon/michal/experiments/checkpoint/nasz_ckpt.ckpt
+# @ queue
+
Index: /experiments/5_1_wait/a.c
===================================================================
--- /experiments/5_1_wait/a.c	(revision 16)
+++ /experiments/5_1_wait/a.c	(revision 16)
@@ -0,0 +1,145 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <llapi.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <time.h>
+#include <string.h>
+#include <errno.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#define CHAR_BUFFER 256
+#define FILE_LENGTH 1024
+
+int createCmd(char *prog, char *params, char *addr, size_t adrrLength)
+{	
+
+	FILE * fd;
+	fd = fopen(addr,"wx");	
+	if(fd!=NULL)
+	{
+		fprintf(fd,"# File created by LoadLeveler DRMAA. If no LL DRMAA aplications are running you can delete this file\n");
+		fprintf(fd,"# @ initialdir = %s\n","/home/mamon/michal/5_1_wait");
+		fprintf(fd,"# @ executable = %s\n",prog);
+		fprintf(fd,"# @ arguments = %s\n",params);
+		fprintf(fd,"# @ output = %s.out\n",prog);
+		fprintf(fd,"# @ error = %s.err\n",prog);
+		fprintf(fd,"# @ queue\n");
+		fclose(fd);
+	}
+	else
+	{
+		perror("Can't create cmd file\n");  //przetestowac
+		exit(1);
+	}
+	return 0;
+}
+
+int compare(char *ad1,char *ad2,size_t l1,size_t l2)
+{
+	int i = 0;
+	size_t min = l2;
+	char * inx = ad2;
+	if(l1<l2) 
+	{
+		min = l1;
+		inx = ad1;
+	}
+	
+	for(i = 0;i<min;i++)
+		if(ad1[i]!=ad2[i]) return 0;	
+
+	return 1; 
+}
+
+int endState(char *buffer,size_t length)
+{
+	if(compare(buffer,"JOB_COMPLETED",length,sizeof("JOB_COMPLETED")) || 
+		compare(buffer,"JOB_REJECTED",length,sizeof("JOB_REJECTED")) ||
+		compare(buffer,"JOB_REMOVED",length,sizeof("JOB_REMOVED")) ||
+		compare(buffer,"JOB_NOTRUN",length,sizeof("JOB_NOTRUN")) ||
+		compare(buffer,"JOB_VACATED",length,sizeof("JOB_VACATED")) )
+		return 1;
+	else
+		return 0;
+}
+
+int fgetline(char str[], int maxlen, FILE *fp)
+{
+	int last;
+	if(!fgets(str, maxlen, fp))
+		return -1;
+	last = strlen(str)-1;
+	if(str[last]=='\n') str[last] = '\0';
+	return 0;
+}
+
+int main(int argc, char *argv[])
+{
+	LL_job test;
+	int status;
+	char *mon = "/home/mamon/michal/5_1_wait/mon";
+	FILE * fd;
+	char *prog;
+	char *fifoAddr;
+	char templateCmd[] = "/tmp/drmaa_cmd_XXXXXX";
+	char templateFifo[] = "/tmp/drmaa_fifo_XXXXXX";
+
+	if (argc<2) 
+	{
+		fprintf(stderr, "usage: example <path-to-job> [args]\n");
+		return 1;
+	}
+
+	
+	prog=mktemp(templateCmd);
+	
+	if(argc==3)
+		createCmd(argv[1],argv[2],prog,CHAR_BUFFER);
+	else
+		createCmd(argv[1],"",prog,CHAR_BUFFER);
+	
+	fifoAddr=mktemp(templateFifo);
+
+	status = llsubmit(prog,mon,fifoAddr,&test,LL_JOB_VERSION); 
+
+	remove(prog);
+	llfree_job_info(&test,LL_JOB_VERSION);
+
+	if(status==0)
+	{
+		char buffer[CHAR_BUFFER];
+		int idGot=1;
+		//int i = 3;
+		
+		mkfifo(fifoAddr,0600);
+		fd=fopen(fifoAddr,"r"); //x
+		
+		do
+		{
+			if(fgetline(buffer,sizeof(buffer),fd)!=-1)
+			{
+				if(idGot==1)
+				{
+					idGot=0;
+					printf("Your job has been submitted with id %s\n",buffer);
+				}
+			}
+			//printf("a: %s\n",buffer);
+		} while(!endState(buffer,sizeof(buffer)));
+		printf("End state: %s\n",buffer);
+	 	fgetline(buffer,sizeof(buffer),fd);
+		printf("Exit status: %s\n",buffer);
+		
+		fclose(fd);
+
+		unlink(fifoAddr);	
+	}
+	else
+		printf("error\n");
+
+	return 0;
+}
Index: /experiments/5_1_wait/mon.c
===================================================================
--- /experiments/5_1_wait/mon.c	(revision 16)
+++ /experiments/5_1_wait/mon.c	(revision 16)
@@ -0,0 +1,30 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <llapi.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <time.h>
+#include <string.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <time.h> 
+
+#include <sys/types.h>
+#include <sys/ipc.h>
+#include <sys/msg.h>
+
+#define CHAR_BUFFER 256
+#define FILE_LENGTH 256
+
+int main(int argc, char *argv[])
+{
+	FILE * fd;
+	mkfifo(argv[2],0600);
+	fd=fopen(argv[2],"w");
+	fprintf(fd,"%s\n",argv[1]);
+	fprintf(fd,"%s\n",argv[3]);
+	fprintf(fd,"%s\n",argv[4]);
+	fclose(fd);
+	return 0;
+}
Index: /experiments/5_5_ckpt/test.c
===================================================================
--- /experiments/5_5_ckpt/test.c	(revision 16)
+++ /experiments/5_5_ckpt/test.c	(revision 16)
@@ -0,0 +1,115 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <llapi.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <string.h>
+#include <errno.h>
+#include <assert.h>
+
+#define LL_CKPT_UNCLEAR 1
+#define LL_CKPT_ERROR -1
+#define LL_CKPT_JOB_ID_ERR -2
+#define LL_CKPT_MALLOC_ERR -3
+#define LL_CKPT_SOCKET_ERR -4
+#define LL_CKPT_CONF_ERR -6
+
+const char *
+lldrmaa_err_ckpt(int _llerrno)
+{
+	switch(_llerrno)
+	{
+		case API_OK:
+			return "Checkpoint completed successfully.";
+		case LL_CKPT_UNCLEAR:
+			return "Checkpoint event did not receive status and the success or failure of the checkpoint is unclear.";
+		case LL_CKPT_ERROR:
+			return "Error occurred attempting to checkpoint.";
+		case LL_CKPT_JOB_ID_ERR:
+			return "Format not valid for job step, not in the form host.jobid.stepid.";
+		case LL_CKPT_MALLOC_ERR:
+			return "Cannot allocate memory.";
+		case LL_CKPT_SOCKET_ERR:
+			return "API cannot create listen socket.";
+		case LL_CKPT_CONF_ERR:
+			return "Configuration file errors.";	
+		default:
+			assert(0);
+			return "Invalid error code";
+	}
+}
+/*
+int 
+lldrmaa_map_ckpt(int _llerrno)
+{
+	switch(_llerrno)
+	{
+		case API_OK:
+			return FSD_ERRNO_SUCCESS;
+		case LL_CKPT_UNCLEAR:
+			return FSD_ERRNO_INTERNAL_ERROR;
+		case LL_CKPT_ERROR:
+			return FSD_DRMAA_ERRNO_SUSPEND_INCONSISTENT_STATE;
+		case LL_CKPT_JOB_ID_ERR:
+			return FSD_ERRNO_INTERNAL_ERROR;
+		case LL_CKPT_MALLOC_ERR:
+			return FSD_ERRNO_NO_MEMORY;
+		case LL_CKPT_SOCKET_ERR:
+			return FSD_ERRNO_INTERNAL_ERROR;
+		case LL_CKPT_CONF_ERR:
+			return FSD_ERRNO_DENIED_BY_DRM;
+		default:
+			fsd_assert(false);
+			return FSD_ERRNO_INTERNAL_ERROR;
+	}
+}
+*/
+
+void ckpt_job(char * job_id)
+{
+	int rc = 0;
+	char buf[256];
+	cr_error_t cp;
+	LL_ckpt_info ckpt_info;
+	ckpt_info.version=LL_API_VERSION;
+	ckpt_info.step_id=strdup(job_id);
+	ckpt_info.ckptType=CKPT_AND_TERMINATE;
+	ckpt_info.waitType=CKPT_NO_WAIT; 
+	ckpt_info.abort_sig=SIGINT;
+	ckpt_info.cp_error_data=NULL;
+	ckpt_info.ckpt_rc = 0;
+	ckpt_info.soft_limit = 0;
+	ckpt_info.hard_limit = 0;
+	
+	rc = ll_ckpt(&ckpt_info); /* TODO: segfault */
+	
+	if(rc) 
+	{
+	printf("job::control: could  to job %s. Error code: %d,%s\n", job_id, rc, lldrmaa_err_ckpt(rc)	);
+	
+		printf("Return code from checkpoint: %d\n",ckpt_info.ckpt_rc);
+		printf("Error data: %s\n",cp.error_data);
+		strerror_r(cp.Py_error,buf,256);
+		printf("cp_error_data  %d: %s\n",cp.Py_error,buf);
+		strerror_r(cp.Sy_error,buf,256);
+		printf("cp_error_data2  %d: %s\n",cp.Sy_error,buf);
+	}
+}
+
+int main(int argc, char *argv[])
+{
+	if(argc<2)
+	{
+		printf("./a <job_id>\n");
+		exit(1);
+	}
+
+	printf("Trying to checkpoint %s\n",argv[1]);
+	
+	ckpt_job(argv[1]);
+	llsubmit(NULL,NULL,NULL,NULL,0);
+	printf("After ckpt\n");
+	
+	return 0;
+}
Index: /experiments/5_5_ckpt/prog.cmd
===================================================================
--- /experiments/5_5_ckpt/prog.cmd	(revision 16)
+++ /experiments/5_5_ckpt/prog.cmd	(revision 16)
@@ -0,0 +1,15 @@
+#   The name of this job command file is file.cmd.
+#   The input file is longjob.in1 and the error file is
+#   longjob.err1. The queue statement marks the end of
+#   the job step.
+# @ initialdir = /home/mamon/michal/experiments/5_5_ckpt
+# @ executable = /bin/sleep
+# @ arguments = 50
+# @ output = test.out
+# @ error = test.err
+# @ checkpoint = yes
+#  ckpt_dir = /home/mamon/michal/experiments/5_5_ckpt
+#  ckpt_execute_dir = /home/mamon/michal/experiments/5_5_ckpt
+#  ckpt_file = /home/mamon/michal/experiments/5_5_ckpt/nasz_ckpt.ckpt
+# @ queue
+
Index: /experiments/5_5_ckpt/Makefile
===================================================================
--- /experiments/5_5_ckpt/Makefile	(revision 16)
+++ /experiments/5_5_ckpt/Makefile	(revision 16)
@@ -0,0 +1,7 @@
+test : test.c
+	gcc -Wall test.c -o test -I/usr/lpp/LoadL/full/include/ -lllapi
+
+.PHONY: clean
+
+clean :
+	rm test
Index: /experiments/Divide_job_id/a.c
===================================================================
--- /experiments/Divide_job_id/a.c	(revision 16)
+++ /experiments/Divide_job_id/a.c	(revision 16)
@@ -0,0 +1,59 @@
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+void divide(char * job_id)
+{
+	char * a,b,c,temp,pta;
+	/*a = (char *)malloc(30*sizeof(char*));
+	b = (char *)malloc(30*sizeof(char*));
+	c = (char *)malloc(30*sizeof(char*));*/
+	/*temp = (char *)malloc(30*sizeof(char*));*/
+	int i;
+	/*temp = strdup(job_id);*/
+	/*size_t l = strspn(job_id,".");*/
+	/*strncpy(a, job_id, strchr(job_id,'.') - job_id );*/
+	/*strncpy(temp, job_id, strlen(job_id) - strlen(a) -1 );
+	*//*strncpy(b, job_id, strchr(temp,'.') - temp  );*/
+	
+    char *rest; 
+    char *token; 
+    char *ptr = job_id; 
+
+      
+  /*  while(token = strtok_r(ptr, ".", &rest)) {
+
+            printf("%s\n", token); 
+            ptr = rest; 
+    }*/
+	
+	token = strtok_r(ptr, ".", &rest);
+	printf("%s\n", token); 
+    ptr = rest; 
+	token = strtok_r(ptr, ".", &rest);
+	printf("%s\n", token); 
+    ptr = rest; 
+	token = strtok_r(ptr, ".", &rest);
+	printf("%s\n", token); 
+    ptr = rest; 
+	
+	/*for(i = 0;i<strlen(job_id);i++)
+	{
+		if(job_id[i] == ".")
+		
+	}*/
+	
+	
+	
+	
+
+}
+
+int main(int argc, char *argv[])
+{
+	if(argc<2)
+		exit(1);
+	
+	divide(argv[1]);
+	return 0;
+}
Index: /experiments/Return_test/monitor_program.c
===================================================================
--- /experiments/Return_test/monitor_program.c	(revision 16)
+++ /experiments/Return_test/monitor_program.c	(revision 16)
@@ -0,0 +1,118 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <llapi.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <time.h>
+#include <string.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <time.h> 
+
+#include <sys/types.h>
+#include <sys/ipc.h>
+#include <sys/msg.h>
+
+#define CHAR_BUFFER 256
+#define FILE_LENGTH 256
+
+void reverse(char s[])
+{
+	int c,i,j;
+
+	for(i=0,j=strlen(s)-1;i<j;i++,j--){
+		c=s[i];
+		s[i]=s[j];
+		s[j]=c;
+	}
+}
+
+void itoa(int n,char s[])
+{
+	int i, sign;
+	
+	if((sign = n) <0)
+		n=-n;
+	i=0;
+	do{
+		s[i++]=n%10+'0';
+	} while((n/=10)>0);
+	if(sign<0)
+		s[i++]='-';
+	s[i]='\0';
+	reverse(s);
+}
+
+int main(int argc, char *argv[])
+{
+	int fd = -1;
+	int fp;
+	char* file;
+	char buf[CHAR_BUFFER]="";
+	char adrr[256] = "/home/mamon/michal/Return_test/test_mon.txt";
+	uid_t id;
+	time_t rawtime;
+	struct tm * timeinfo;
+
+	time ( &rawtime );
+	timeinfo = localtime ( &rawtime );  	
+
+	fd = open(adrr,O_WRONLY | O_CREAT | O_APPEND, 0644); // DRMAA powinna byc thread-safe, wiec nazwa pliku musi byc za kazdym razem inna
+	if(fd==-1)
+		exit(0);
+	
+	file = malloc(FILE_LENGTH);
+	memset(file,'\0',FILE_LENGTH);
+	strftime (file, 40, "[%x %X] \n",timeinfo); 
+	write(fd,file,FILE_LENGTH);
+
+	memset(file,'\0',FILE_LENGTH);
+	gethostname(buf,CHAR_BUFFER);
+	/*strcat(file,"Hostname: ");
+	strcat(file,buf);
+	strcat(file,"\n");*/
+	sprintf(file,"Hostname: %s\n",buf);
+	write(fd,file,FILE_LENGTH);
+
+	memset(file,'\0',FILE_LENGTH);
+
+	/*memset(buf,'\0',CHAR_BUFFER);
+	strcat(file,"UID: ");
+	id = getuid();
+	itoa(id,buf);
+	strcat(file,buf);
+	strcat(file,"\n");*/
+
+	sprintf(file,"UID: %d\n",getuid());
+	write(fd,file,FILE_LENGTH);
+	
+	memset(file,'\0',FILE_LENGTH);
+	sprintf(file,"Getcwd: ");
+	write(fd,file,FILE_LENGTH);
+
+	memset(file,'\0',FILE_LENGTH);
+	getcwd(file,FILE_LENGTH);
+	strcat(file,"\n");	
+	write(fd,file,FILE_LENGTH);
+
+	memset(file,'\0',FILE_LENGTH);
+	sprintf(file,"argv[1] - job_id: %s\n",argv[1]);	
+	write(fd,file,FILE_LENGTH);
+
+	memset(file,'\0',FILE_LENGTH);
+	sprintf(file,"argv[2] - user_arg: %s\n",argv[2]);	
+	write(fd,file,FILE_LENGTH);
+
+	memset(file,'\0',FILE_LENGTH);
+	sprintf(file,"argv[3] - state: %s\n",argv[3]);	
+	write(fd,file,FILE_LENGTH);
+
+	memset(file,'\0',FILE_LENGTH);
+	sprintf(file,"argv[4] - exit_status: %s\n\n",argv[4]);
+	write(fd,file,FILE_LENGTH);
+
+	close(fd);
+
+	return 0;
+}
Index: /experiments/Return_test/return_test.c
===================================================================
--- /experiments/Return_test/return_test.c	(revision 16)
+++ /experiments/Return_test/return_test.c	(revision 16)
@@ -0,0 +1,10 @@
+#include<stdlib.h>
+#include<stdio.h>
+
+int main(int argc,char *argv[])
+{
+	if(argc<2)
+		return -1;
+	else 
+		return atoi(argv[1]);
+}
Index: /experiments/Return_test/return_test_ap.c
===================================================================
--- /experiments/Return_test/return_test_ap.c	(revision 16)
+++ /experiments/Return_test/return_test_ap.c	(revision 16)
@@ -0,0 +1,114 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <llapi.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <time.h>
+#include <string.h>
+#include <errno.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#define CHAR_BUFFER 256
+#define FILE_LENGTH 1024
+
+int createCmd(char *prog, char *params, char *addr, size_t adrrLength)
+{	
+
+	FILE * fd;
+	fd = fopen(addr,"wx");	
+	if(fd!=NULL)
+	{
+		fprintf(fd,"# File created by LoadLeveler DRMAA. If no LL DRMAA aplications are running you can delete this file\n");
+		fprintf(fd,"# @ initialdir = %s\n","/home/mamon/michal/Return_test");
+		fprintf(fd,"# @ executable = %s\n",prog);
+		fprintf(fd,"# @ arguments = %s\n",params);
+		fprintf(fd,"# @ output = %s.out\n",prog);
+		fprintf(fd,"# @ error = %s.err\n",prog);
+		fprintf(fd,"# @ queue\n");
+		fclose(fd);
+	}
+	else
+	{
+		perror("Can't create cmd file\n");  //przetestowac
+		exit(1);
+	}
+	return 0;
+}
+
+int compare(char *ad1,char *ad2,size_t l1,size_t l2)
+{
+	int i = 0;
+	size_t min = l2;
+	char * inx = ad2;
+	if(l1<l2) 
+	{
+		min = l1;
+		inx = ad1;
+	}
+	
+	for(i = 0;i<min;i++)
+		if(ad1[i]!=ad2[i]) return 0;	
+
+	return 1; 
+}
+
+int endState(char *buffer,size_t length)
+{
+	if(compare(buffer,"JOB_COMPLETED",length,sizeof("JOB_COMPLETED")) || 
+		compare(buffer,"JOB_REJECTED",length,sizeof("JOB_REJECTED")) ||
+		compare(buffer,"JOB_REMOVED",length,sizeof("JOB_REMOVED")) ||
+		compare(buffer,"JOB_NOTRUN",length,sizeof("JOB_NOTRUN")) ||
+		compare(buffer,"JOB_VACATED",length,sizeof("JOB_VACATED")) )
+		return 1;
+	else
+		return 0;
+}
+
+int fgetline(char str[], int maxlen, FILE *fp)
+{
+	int last;
+	if(!fgets(str, maxlen, fp))
+		return -1;
+	last = strlen(str)-1;
+	if(str[last]=='\n') str[last] = '\0';
+	return 0;
+}
+
+int main(int argc, char *argv[])
+{
+	LL_job test;
+	int status;
+	char *mon = "/home/mamon/michal/Return_test/monitor_program";
+	FILE * fd;
+	char *prog;
+	char *fifoAddr;
+	char templateCmd[] = "/tmp/drmaa_cmd_XXXXXX";
+	char templateFifo[] = "/tmp/drmaa_fifo_XXXXXX";
+
+	if (argc<2) 
+	{
+		fprintf(stderr, "usage: example <path-to-job> [args]\n");
+		return 1;
+	}
+
+	
+	prog=mktemp(templateCmd);
+	
+	if(argc==3)
+		createCmd(argv[1],argv[2],prog,CHAR_BUFFER);
+	else
+		createCmd(argv[1],"",prog,CHAR_BUFFER);
+	
+	fifoAddr=mktemp(templateFifo);
+
+	status = llsubmit(prog,mon,fifoAddr,&test,LL_JOB_VERSION); 
+
+	remove(prog);
+	llfree_job_info(&test,LL_JOB_VERSION);
+
+	
+	return 0;
+}
Index: /experiments/monitor_program/monitor_program.c
===================================================================
--- /experiments/monitor_program/monitor_program.c	(revision 16)
+++ /experiments/monitor_program/monitor_program.c	(revision 16)
@@ -0,0 +1,118 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <llapi.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <time.h>
+#include <string.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <time.h> 
+
+#include <sys/types.h>
+#include <sys/ipc.h>
+#include <sys/msg.h>
+
+#define CHAR_BUFFER 256
+#define FILE_LENGTH 256
+
+void reverse(char s[])
+{
+	int c,i,j;
+
+	for(i=0,j=strlen(s)-1;i<j;i++,j--){
+		c=s[i];
+		s[i]=s[j];
+		s[j]=c;
+	}
+}
+
+void itoa(int n,char s[])
+{
+	int i, sign;
+	
+	if((sign = n) <0)
+		n=-n;
+	i=0;
+	do{
+		s[i++]=n%10+'0';
+	} while((n/=10)>0);
+	if(sign<0)
+		s[i++]='-';
+	s[i]='\0';
+	reverse(s);
+}
+
+int main(int argc, char *argv[])
+{
+	int fd = -1;
+	int fp;
+	char* file;
+	char buf[CHAR_BUFFER]="";
+	char adrr[256] = "/home/mamon/michal/5_1/test_mon.txt";
+	uid_t id;
+	time_t rawtime;
+	struct tm * timeinfo;
+
+	time ( &rawtime );
+	timeinfo = localtime ( &rawtime );  	
+
+	fd = open(adrr,O_WRONLY | O_CREAT | O_APPEND, 0644); // DRMAA powinna byc thread-safe, wiec nazwa pliku musi byc za kazdym razem inna
+	if(fd==-1)
+		exit(0);
+	
+	file = malloc(FILE_LENGTH);
+	memset(file,'\0',FILE_LENGTH);
+	strftime (file, 40, "[%x %X] \n",timeinfo); 
+	write(fd,file,FILE_LENGTH);
+
+	memset(file,'\0',FILE_LENGTH);
+	gethostname(buf,CHAR_BUFFER);
+	/*strcat(file,"Hostname: ");
+	strcat(file,buf);
+	strcat(file,"\n");*/
+	sprintf(file,"Hostname: %s\n",buf);
+	write(fd,file,FILE_LENGTH);
+
+	memset(file,'\0',FILE_LENGTH);
+
+	/*memset(buf,'\0',CHAR_BUFFER);
+	strcat(file,"UID: ");
+	id = getuid();
+	itoa(id,buf);
+	strcat(file,buf);
+	strcat(file,"\n");*/
+
+	sprintf(file,"UID: %d\n",getuid());
+	write(fd,file,FILE_LENGTH);
+	
+	memset(file,'\0',FILE_LENGTH);
+	sprintf(file,"Getcwd: ");
+	write(fd,file,FILE_LENGTH);
+
+	memset(file,'\0',FILE_LENGTH);
+	getcwd(file,FILE_LENGTH);
+	strcat(file,"\n");	
+	write(fd,file,FILE_LENGTH);
+
+	memset(file,'\0',FILE_LENGTH);
+	sprintf(file,"argv[1] - job_id: %s\n",argv[1]);	
+	write(fd,file,FILE_LENGTH);
+
+	memset(file,'\0',FILE_LENGTH);
+	sprintf(file,"argv[2] - user_arg: %s\n",argv[2]);	
+	write(fd,file,FILE_LENGTH);
+
+	memset(file,'\0',FILE_LENGTH);
+	sprintf(file,"argv[3] - state: %s\n",argv[3]);	
+	write(fd,file,FILE_LENGTH);
+
+	memset(file,'\0',FILE_LENGTH);
+	sprintf(file,"argv[4] - exit_status: %s\n\n",argv[4]);
+	write(fd,file,FILE_LENGTH);
+
+	close(fd);
+
+	return 0;
+}
Index: /experiments/LL_API_test_1/lltest.c
===================================================================
--- /experiments/LL_API_test_1/lltest.c	(revision 16)
+++ /experiments/LL_API_test_1/lltest.c	(revision 16)
@@ -0,0 +1,16 @@
+#include <stdio.h>
+#include <llapi.h>
+
+int main(int argc, char *argv[])
+{
+			LL_job test;
+			int status;
+		    printf("start\n");
+			status = llsubmit(argv[1],NULL,NULL,&test,LL_JOB_VERSION);
+		    llfree_job_info(&test,LL_JOB_VERSION);
+			if(status==0)
+			printf("done\n");
+			else
+					printf("error\n");
+			return 0;
+}
Index: /experiments/LL_API_test_1/prog.cmd
===================================================================
--- /experiments/LL_API_test_1/prog.cmd	(revision 16)
+++ /experiments/LL_API_test_1/prog.cmd	(revision 16)
@@ -0,0 +1,15 @@
+#   The name of this job command file is file.cmd.
+#   The input file is longjob.in1 and the error file is
+#   longjob.err1. The queue statement marks the end of
+#   the job step.
+# @ initialdir = /home/mamon/michal/experiments/LL_API_test_1
+# @ executable = /bin/sleep
+# @ arguments = 10000
+# @ output = silnia.out
+# @ error = silnia.err
+# @ checkpoint = yes
+# @ ckpt_dir = /work/default/mamon
+# @ ckpt_execute_dir = /work/default/mamon
+# @ ckpt_file = /work/default/mamon/tabs.ckpt
+# @ queue
+
Index: /experiments/LL_API_test_1/prog2.cmd
===================================================================
--- /experiments/LL_API_test_1/prog2.cmd	(revision 16)
+++ /experiments/LL_API_test_1/prog2.cmd	(revision 16)
@@ -0,0 +1,12 @@
+#   The name of this job command file is file.cmd.
+#   The input file is longjob.in1 and the error file is
+#   longjob.err1. The queue statement marks the end of
+#   the job step.
+# @ initialdir = /home/mamon/michal/experiments/LL_API_test_1
+# @ executable = /bin/sleep
+# @ arguments = 1
+# @ input = not_existing_file
+# @ output = /etc/passwd
+# @ error = /etc/passwd
+# @ queue
+
Index: /experiments/LL_API_test_1/Makefile
===================================================================
--- /experiments/LL_API_test_1/Makefile	(revision 16)
+++ /experiments/LL_API_test_1/Makefile	(revision 16)
@@ -0,0 +1,7 @@
+LL_API_test_1 : LL_API_test_1.c
+	gcc -Wall LL_API_test_1.c -o LL_API_test_1 -I/usr/lpp/LoadL/full/include/
+
+.PHONY: clean
+
+clean :
+	rm LL_API_test_1
Index: /experiments/LL_API_test_1/LL_API_test_1.c
===================================================================
--- /experiments/LL_API_test_1/LL_API_test_1.c	(revision 16)
+++ /experiments/LL_API_test_1/LL_API_test_1.c	(revision 16)
@@ -0,0 +1,9 @@
+#include <stdio.h>
+#include <llapi.h>
+int main()
+{
+	printf("tabs\n");
+	llinit(5);
+	return 0;
+}
+
Index: /experiments/LL_API_test_1/silnia.c
===================================================================
--- /experiments/LL_API_test_1/silnia.c	(revision 16)
+++ /experiments/LL_API_test_1/silnia.c	(revision 16)
@@ -0,0 +1,19 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+int main(int argc, char **argv) 
+{
+	int i = 0,w=1;
+	if(argc<2)
+	{
+		fprintf(stderr,"N?\n");
+		return 1;
+	}
+	
+	for(i=2;i<=atoi(argv[1]);i++)
+		w*=i;
+		
+	fprintf(stdout,"Silnia z %s to %d\n",argv[1],w);
+	
+	return 0;
+}
Index: /experiments/Join_files_test/Makefile
===================================================================
--- /experiments/Join_files_test/Makefile	(revision 16)
+++ /experiments/Join_files_test/Makefile	(revision 16)
@@ -0,0 +1,7 @@
+a : a.c
+	gcc -Wall -I/usr/lpp/LoadL/full/include/ a.c -o a -lllapi
+
+.PHONY: clean
+
+clean :
+	rm a
Index: /experiments/Join_files_test/w.err
===================================================================
--- /experiments/Join_files_test/w.err	(revision 16)
+++ /experiments/Join_files_test/w.err	(revision 16)
@@ -0,0 +1,6 @@
+err test1
+err test2
+err test3
+out test1
+out test2
+out test3
Index: /experiments/Join_files_test/a.c
===================================================================
--- /experiments/Join_files_test/a.c	(revision 16)
+++ /experiments/Join_files_test/a.c	(revision 16)
@@ -0,0 +1,13 @@
+#include <llapi.h>
+#include <stdlib.h>
+
+int main(int argc,char *argv[])
+{
+	fprintf(stdout,"out test1\n");
+	fprintf(stderr,"err test1\n");
+	fprintf(stdout,"out test2\n");
+	fprintf(stderr,"err test2\n");
+	fprintf(stdout,"out test3\n");
+	fprintf(stderr,"err test3\n");
+	return 0;
+}
Index: /experiments/Join_files_test/test.cmd
===================================================================
--- /experiments/Join_files_test/test.cmd	(revision 16)
+++ /experiments/Join_files_test/test.cmd	(revision 16)
@@ -0,0 +1,11 @@
+#   The name of this job command file is file.cmd.
+#   The input file is longjob.in1 and the error file is
+#   longjob.err1. The queue statement marks the end of
+#   the job step.
+# @ initialdir = /home/mamon/michal/Join_files_test
+# @ executable = /home/mamon/michal/Join_files_test/a
+# @ arguments = 
+# @ output = p.out
+# @ error = p.out
+# @ queue
+
Index: /experiments/Join_files_test/p.out
===================================================================
--- /experiments/Join_files_test/p.out	(revision 16)
+++ /experiments/Join_files_test/p.out	(revision 16)
@@ -0,0 +1,6 @@
+err test1
+err test2
+err test3
+out test1
+out test2
+out test3
Index: /experiments/5_4_job_control/a.c
===================================================================
--- /experiments/5_4_job_control/a.c	(revision 16)
+++ /experiments/5_4_job_control/a.c	(revision 16)
@@ -0,0 +1,243 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <llapi.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <time.h>
+#include <string.h>
+#include <errno.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#define CHAR_BUFFER 256
+#define FILE_LENGTH 1024
+
+void getStatus(char* jobid)
+{
+char * name=NULL;
+	enum StepState step_state;
+	int rc;
+	int  obj_count,err_code;
+	LL_element * job=NULL,*data=NULL,*step=NULL;
+	char **host_list;
+	
+	
+	job = ll_query(JOBS);
+	if (!job) {
+      		printf("Query JOBS: ll_query() returns NULL.\n"); exit(1);
+  	}
+	
+	host_list = (char **)malloc(2*sizeof(char *));
+	host_list[0] = jobid;
+	host_list[1] = NULL;
+
+	rc = ll_set_request(job,QUERY_JOBID,host_list,ALL_DATA);
+	if (rc) {
+      		printf("Query JOBS: ll_set_request() return code is non-zero.\n"); exit(1);
+  	}
+	
+
+	data = ll_get_objs(job, LL_SCHEDD, NULL, &obj_count, &err_code);
+  	if (data == NULL) {
+      		printf("Query JOBS: ll_get_objs() returns NULL. Error code = %d\n", err_code);
+   	}
+	//printf("Number of jobs objects returned = %d\n", obj_count);
+
+	name=(char*)malloc(256*sizeof(char *));
+
+      ll_get_data(data, LL_JobGetFirstStep, &step);
+    
+
+	while(data) {
+
+     		rc = ll_get_data(data, LL_JobName,&name);
+
+      		if (!rc) {
+         		printf("Job name: %s\n",name);
+			free(name);
+      		}
+		//free(step_state);
+      		rc = ll_get_data(step, LL_StepState,&step_state);
+      		if (rc) {
+         		printf("Query MACHINES: ll_get_data() return code is non-zero.\n"); 
+			exit(1);
+      		}
+		
+		if(!rc) {
+    			printf("State: %d\n",step_state);
+			
+		}		
+
+      		data = ll_next_obj(job);
+   	}
+
+	ll_free_objs(job);
+    	ll_deallocate(job);
+
+}
+
+void changeStatus(char *jobid,char *state)
+{
+	int st = atoi(state);
+	
+	int rt;
+	char **job_list;
+			job_list = (char **)malloc(2*sizeof(char*));
+			job_list[0] = jobid;
+			job_list[1] = NULL;
+			
+	LL_element *errObj;
+	LL_preempt_param  *param_struct;		
+	
+	LL_terminate_job_info *cancel_info;
+	char *rest; 
+    char *token; 
+    char *ptr = jobid;	
+	int n,i;
+	switch(st)
+	{
+		case 0:			
+			param_struct->type=PREEMPT_STEP;
+			param_struct->method=LL_PREEMPT_SUSPEND; //?
+			param_struct->user_list=NULL;
+			param_struct->host_list=NULL;
+			param_struct->job_list=job_list;
+			printf("DRMAA_CONTROL_SUSPEND\n");
+			rt = ll_preempt_jobs(LL_API_VERSION,errObj,&param_struct);
+			printf("ll_preempt_jobs - PREEMPT_STEP returned: %d\n",rt);
+			break;
+
+		case 1:
+			param_struct->type=RESUME_STEP;
+			param_struct->method=LL_PREEMPT_SUSPEND; //?
+			param_struct->user_list=NULL;
+			param_struct->host_list=NULL;
+			param_struct->job_list=job_list;
+			printf("DRMAA_CONTROL_RESUME\n");
+			rt = ll_preempt_jobs(LL_API_VERSION,errObj,&param_struct);
+			printf("ll_preempt_jobs - RESUME_STEP returned: %d\n",rt);
+			break;
+
+		case 2:
+			printf("DRMAA_CONTROL_HOLD\n");
+			rt = ll_control(LL_CONTROL_VERSION, LL_CONTROL_HOLD_USER, NULL,NULL,job_list,NULL,0);
+			printf("LL_control - LL_CONTROL_HOLD_USER returned: %d, jobid %s\n",rt,jobid);
+			break;
+
+		case 3:
+			printf("DRMAA_CONTROL_RELEASE\n");
+			rt = ll_control(LL_CONTROL_VERSION, LL_CONTROL_HOLD_RELEASE, NULL,NULL,job_list,NULL,0);
+			printf("LL_control - LL_CONTROL_HOLD_RELEASE returned: %d, jobid %s\n",rt,jobid);
+			break;
+
+		case 4:
+			cancel_info = (LL_terminate_job_info *)malloc(sizeof(LL_terminate_job_info));
+			if (!cancel_info) {
+				fprintf(stderr, "Out of memory.\n");
+				exit(1);
+			}
+			
+			cancel_info->version_num=LL_PROC_VERSION;
+			
+			/*cancel_info->StepId.from_host="l4f1n03";
+			cancel_info->StepId.cluster=16651;
+			cancel_info->StepId.proc = 0;*/
+			token = strtok_r(ptr, ".", &rest);
+			cancel_info->StepId.from_host =  strdup(token);
+			ptr = rest; 
+			token = strtok_r(ptr, ".", &rest);
+   			ptr = rest; 
+			
+				cancel_info->StepId.cluster = atoi(token);
+			token = strtok_r(ptr, ".", &rest);
+	/*  			  ptr = rest; 		*/
+			if(token!=NULL)
+			{
+				cancel_info->StepId.proc = atoi(token);
+			}
+			else
+			{
+				enum StepState step_state;
+				int rc;
+				int  obj_count,err_code;
+				LL_element * job=NULL,*data=NULL,*step=NULL;
+				char **host_list;
+				char * temp = (char *)malloc(30*sizeof(char *));
+				printf("tu3\n");
+				job = ll_query(JOBS);
+				if (!job) {
+     		 		printf("Query JOBS: ll_query() returns NULL.\n"); exit(1);
+  				}	
+				
+				sprintf(temp,"%s.%d",cancel_info->StepId.from_host,cancel_info->StepId.cluster);
+				printf("tu2\n");	
+				host_list = (char **)malloc(2*sizeof(char *));
+				host_list[0] = temp;
+				host_list[1] = NULL;
+				
+				
+				rc = ll_set_request(job,QUERY_JOBID,host_list,ALL_DATA);
+				if (rc) {
+  		    		printf("Query JOBS: ll_set_request() return code is non-zero.\n"); exit(1);
+  				}
+				
+				data = ll_get_objs(job, LL_SCHEDD, NULL, &obj_count, &err_code);
+  				if (data == NULL) {
+  			    		printf("Query JOBS: ll_get_objs() returns NULL. Error code = %d\n", err_code);
+  			 	}
+				printf("obj_c %d\n",obj_count);
+				  ll_get_data(data, LL_JobGetFirstStep, &step);  
+			
+				rc = ll_get_data(data, LL_JobStepCount, &n);
+				printf("Job count: %d\n",n);
+			
+			
+				
+			
+				}
+			/**/
+					
+			printf("Cancel Job Step %s.%d.%d \n\n",
+	        cancel_info->StepId.from_host,
+	        cancel_info->StepId.cluster,
+	        cancel_info->StepId.proc);
+			
+			cancel_info->msg=NULL;
+			printf("DRMAA_CONTROL_TERMINATE\n");
+			for(i = 0; i<n;i++)
+			{
+				cancel_info->StepId.proc = i;
+				rt = ll_terminate_job(cancel_info);
+			}
+			printf("LL_terminate_job returned: %d\n",rt);
+			
+			free(cancel_info->StepId.from_host);
+			free(cancel_info);
+			
+			break;
+
+		default:
+			printf("Wrong state value\n");
+			break;
+
+	}
+	sleep(1);
+}
+
+int main(int argc, char *argv[])
+{
+	if(argc<3)
+	{
+		printf("./a <job_id> <change_to_state>\n");
+		exit(1);
+	}
+
+	getStatus(argv[1]);
+	printf("\n");
+	changeStatus(argv[1],argv[2]);
+	printf("\n");
+	getStatus(argv[1]);
+	return 0;
+}
Index: /experiments/5_2_bulk/a.c
===================================================================
--- /experiments/5_2_bulk/a.c	(revision 16)
+++ /experiments/5_2_bulk/a.c	(revision 16)
@@ -0,0 +1,67 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <llapi.h>
+
+#define CHAR_BUFFER 256
+
+int createBulkCmd(char *prog, char *params, char *addr, size_t adrrLength, int start, int end, int incr)
+{	
+	int i,count = (end-start+1)/incr;
+	FILE * fd;
+	fd = fopen(addr,"wx");	
+	if(fd!=NULL)
+	{
+		fprintf(fd,"# File created by LoadLeveler DRMAA. If no LL DRMAA aplications are running you can delete this file\n");
+		fprintf(fd,"# @ initialdir = %s\n","/home/mamon/michal/5_2_bulk");
+		fprintf(fd,"# @ executable = %s\n",prog);
+		fprintf(fd,"# @ arguments = %s\n",params);
+		fprintf(fd,"# @ output = $(executable).$(jobid).$(stepid).out\n"); //stepname?
+		fprintf(fd,"# @ error =  $(executable).$(jobid).$(stepid).err\n");
+		fprintf(fd,"# @ job_type = parallel\n");
+		for(i=0;i<count;i++)
+		{	
+			//fprintf(fd,"# @ step_name = %s\n",start+i*incr);
+			fprintf(fd,"# @ queue\n");
+		}
+		fclose(fd);
+	}
+	else
+	{
+		perror("Can't create cmd file\n");  //przetestowac
+		exit(1);
+	}
+	return 0;
+}
+
+int main(int argc, char *argv[])
+{
+	int i=0;
+	LL_job test;
+	int status;
+	char templateCmd[] = "/tmp/drmaa_cmd_XXXXXX";
+	char *prog;
+	if(argc<6)
+	{
+		printf("./a <program> <start> <end> <incr> [params] \n");
+		exit(1);
+	}
+	
+	
+	prog=mktemp(templateCmd);
+	
+	if(argc==6)
+		createBulkCmd(argv[1],argv[5],prog,CHAR_BUFFER,atoi(argv[2]),atoi(argv[3]),atoi(argv[4]));
+	else
+		createBulkCmd(argv[1],"",prog,CHAR_BUFFER,atoi(argv[2]),atoi(argv[3]),atoi(argv[4]));
+	
+	status = llsubmit(prog,NULL,NULL,&test,LL_JOB_VERSION); 
+	
+	remove(prog);
+	printf("submitted bulk job with jobids:\n");
+	for(i=0;i<test.steps;i++)
+		printf("\t\"%s.%s\"\n",test.job_name,test.step_list[i]->step_name);
+	
+	llfree_job_info(&test,LL_JOB_VERSION);
+	
+	return 0;
+}
Index: /experiments/5_3_job_status/a.c
===================================================================
--- /experiments/5_3_job_status/a.c	(revision 16)
+++ /experiments/5_3_job_status/a.c	(revision 16)
@@ -0,0 +1,87 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <llapi.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <time.h>
+#include <string.h>
+#include <errno.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#define CHAR_BUFFER 256
+#define FILE_LENGTH 1024
+
+int main(int argc, char *argv[])
+{
+	char * name=NULL;
+	enum StepState step_state;
+	int rc;
+	int  obj_count,err_code;
+	LL_element * job=NULL,*data=NULL,*step=NULL;
+	char **host_list;
+	
+	
+	job = ll_query(JOBS);
+	if (!job) {
+      		printf("Query JOBS: ll_query() returns NULL.\n"); exit(1);
+  	}
+	
+	host_list = (char **)malloc(2*sizeof(char *));
+	host_list[0] = argv[1];//"l4f1n03.16525";
+	host_list[1] = NULL;
+
+	rc = ll_set_request(job,QUERY_JOBID,host_list,ALL_DATA);
+	if (rc) {
+      		printf("Query JOBS: ll_set_request() return code is non-zero.\n"); exit(1);
+  	}
+	
+
+	data = ll_get_objs(job, LL_SCHEDD, NULL, &obj_count, &err_code);
+  	if (data == NULL) {
+      		printf("Query JOBS: ll_get_objs() returns NULL. Error code = %d\n", err_code);
+   	}
+	//printf("Number of jobs objects returned = %d\n", obj_count);
+
+	name=(char*)malloc(256*sizeof(char *));
+
+    ll_get_data(data, LL_JobGetFirstStep, &step);   
+
+	while(data) {
+		int n;
+     		rc = ll_get_data(data, LL_JobName,&name);
+
+      		if (!rc) {
+         		printf("Job name: %s\n",name);
+			free(name);
+      		}
+			
+			rc = ll_get_data(data, LL_JobStepCount, &n);
+			printf("Job count: %d\n",n);
+		//free(step_state);
+      		rc = ll_get_data(step, LL_StepState,&step_state);
+      		if (rc) {
+         		printf("Query MACHINES: ll_get_data() return code is non-zero.\n"); 
+			exit(1);
+      		}
+
+		
+		if(!rc) {
+    			printf("State: %d\n",step_state);
+			
+		}		
+
+      		data = ll_next_obj(job);
+   	}
+	
+
+	
+
+	ll_free_objs(job);
+    	ll_deallocate(job);
+
+
+	return 0;
+}
