コード例 #1
0
ファイル: main.c プロジェクト: magnealvnor/Sanntidssystemer
static void task1(void *argpointer){
    /* get task method */
    int method = *((int *) argpointer);
    free(argpointer);
    int id = 1;

    sync_threads(id);

    rt_task_sleep(1000000);

    rt_printf("Task %i start\n", id);
    busy_wait_ms(5);
    rt_printf("Task %i stop \n", id);
}
コード例 #2
0
ファイル: main.c プロジェクト: magnealvnor/Sanntidssystemer
static void task0(void *argpointer){
    /* get task method */
    int method = *((int *) argpointer);
    free(argpointer);
    int id = 0;

    sync_threads(id);

    /* get resource */
    get_resource(method, id);

    /* do work */
    rt_printf("Task %i start\n", id);
    busy_wait_ms(3);
    
    /* release resource */
    release_resource(method, id);
}
コード例 #3
0
ファイル: dct_pth_host.c プロジェクト: troore/xillybench
void *half_dct_2d_pth_0(void *params)
{
	int i;
	TP0Params *p = (TP0Params *)params;

#ifdef FPGA
	dct_data_t *in, *out;
	int len;

	len = SFN * DCT_SIZE * DCT_SIZE;
	in = (dct_data_t *)malloc((1 + len) * sizeof(dct_data_t));
	in[0] = 0;
	for (i = 1; i <= len; i++)
		in[i] = p->col_inbuf[i - 1];
	out = p->col_outbuf;
#endif

	for (i = 1; i < FF; i++) {
#ifdef FPGA
		write(fdw, (void *)in, (len + 1) * sizeof(dct_data_t));
		read(fdr, (void *)out, len * sizeof(dct_data_t));
#else
		dct_2d(p->col_inbuf, p->col_outbuf);
#endif

		transpose(p->col_outbuf, p->buf_2d_out);
		
		sync_threads();
		
		if (i + 1 < FF) {
			read_data(p->input + (i + 1) * SFN * N, p->nii_block);
		}
		write_data(p->buf_2d_out, p->output + (i - 1) * SFN * N);

		//	sync_threads();
	}

#ifdef FPGA
	free(in);
#endif

	return NULL;
}
コード例 #4
0
ファイル: main.c プロジェクト: magnealvnor/Sanntidssystemer
static void task2(void *argpointer){
    /* get method */
    int method = *((int *) argpointer);
    free(argpointer);
    int id = 2;

    sync_threads(id);

    rt_task_sleep(2000000);

    /* Get resource */
    get_resource(method, id);
    
    /* Simulate work */
    rt_printf("Task %i start \n", id);
    busy_wait_ms(2);

    /* Release resource */
    release_resource(method, id);
}
コード例 #5
0
ファイル: dct_pth_host.c プロジェクト: troore/xillybench
void *half_dct_2d_pth_1(void *params)
{
	int i;
	Params *p = (Params *)params;

#ifdef FPGA
	dct_data_t *in, *out;
	int len;

	len = SFN * DCT_SIZE * DCT_SIZE;
	in = (dct_data_t *)malloc((1 + len) * sizeof(dct_data_t));
	in[0] = 1;
	for (i = 1; i <= len; i++)
		in[i] = p->buf_2d_in[i - 1];
	out = p->row_outbuf;
#endif

	for (i = 1; i < FF; i++) {
#ifdef FPGA
		write(fdw, (void *)in, (len + 1) * sizeof(dct_data_t));
		read(fdr, (void *)out, len * sizeof(dct_data_t));
#else
		dct_2d(p->buf_2d_in, p->row_outbuf);
#endif
		transpose(p->row_outbuf, p->col_inbuf);
		
		sync_threads();
		
		if (i + 1 < FF) {
			block_memcpy(p->col_inbuf, p->nii_block);
		}

		//	sync_threads();
	}

#ifdef FPGA
	free(in);
#endif

	return NULL;
}
コード例 #6
0
ファイル: thread.c プロジェクト: hajelav/programs
int main(){

    char c;
    int choice;
    int m, n;

    do {
	printf("MENU OPTIONS\n");
	printf("1 -- Using threads for synchronisation\n");
	printf("2 -- Thread printing even and odd numbers\n");
	printf("3 -- Printing m numbers(1 to m) alternatively using n threads\n");

	printf("\n");
	printf("Enter your choice\n");
	scanf("%d",&choice);
	switch(choice){
	    case 1:
		sync_threads();
		break;

	    case 2:
		even_odd_print();
		break;

	    case 3:
		printf("Enter m\n");
		scanf("%d", &m);
		printf("Enter no of threads\n");
		scanf("%d", &n);
		print_numbers(m, n);
		break;

	    default:
		break;
	}
	printf("\n\n");
    } while((c=getchar())!='q'); 
    return 0;
}