int main(int argc, char **argv) { int *array; int array_size; int nThreads; int i; if (argc != 3) { printf("Usage:\n\t%s <array_size> <nthreads>\n", argv[0]); exit(1); } array_size = atoi(argv[1]); nThreads = atoi(argv[2]); assert(array_size > 0); #pragma css start(nThreads) /* alloc spaces for the option data */ #pragma css malloc array = (int*)malloc( array_size * sizeof(int) ); #pragma css sync ; #pragma css task inout(array[array_size]) in(array_size) task_init(array, array_size); #pragma css task inout(array[array_size]) in(array_size) task_set(array, array_size); #pragma css task in(array[array_size]) in(array_size) task_print(array, array_size); #pragma css task inout(array[array_size]) in(array_size) task_unset(array, array_size); #pragma css task in(array[array_size]) in(array_size) task_print(array, array_size); #pragma css finish return 0; }
void console_task (void *data) { int c, display_count = 0; tcp_socket_t *s; for (;;) { if (peekchar (&debug) < 0) { timer_delay (&timer, 50); if (++display_count == 10) { display_refresh (); display_count = 0; } continue; } c = getchar (&debug); switch (c) { case '\n': case '\r': putchar (&debug, '\n'); printf (&debug, "Transmit: %ld packets, %ld collisions, %ld errors\n", eth.netif.out_packets, eth.netif.out_collisions, eth.netif.out_errors); printf (&debug, "Receive: %ld packets, %ld errors, %ld lost\n", eth.netif.in_packets, eth.netif.in_errors, eth.netif.in_discards); printf (&debug, "Interrupts: %ln\n", eth.intr); printf (&debug, "Free memory: %u bytes\n", mem_available (&pool)); k5600bg1_debug (ð, &debug); puts (&debug, "Local address Port Peer address Port State\n"); for (s=ip.tcp_sockets; s; s=s->next) print_tcp_socket (&debug, s); for (s=ip.tcp_closing_sockets; s; s=s->next) print_tcp_socket (&debug, s); for (s=ip.tcp_listen_sockets; s; s=s->next) print_tcp_socket (&debug, s); if (user_socket) print_socket_data (&debug, user_socket); putchar (&debug, '\n'); break; case 't' & 037: task_print (&debug, 0); task_print (&debug, (task_t*) stack_console); // task_print (&debug, (task_t*) stack_poll); task_print (&debug, (task_t*) stack_tcp); task_print (&debug, (task_t*) eth.stack); task_print (&debug, (task_t*) ip.stack); putchar (&debug, '\n'); break; } } }
int main(int argc, char **argv) { int *array, *block; int array_size, block_size; int nThreads; int i; if (argc != 3) { printf("Usage:\n\t%s <array_size> <nthreads>\n", argv[0]); exit(1); } array_size = atoi(argv[1]); nThreads = atoi(argv[2]); block_size = array_size / nThreads; assert(array_size > 0); assert(block_size > 0); #pragma css start(nThreads) /* alloc spaces for the option data */ #pragma css malloc array = (int*)malloc( array_size * sizeof(int) ); #pragma css sync for (i = 0; i < nThreads; i++) { block = array + i * block_size; #pragma css task inout(block[block_size]) in(block_size) task_init(block, block_size); } for (i = 0; i < nThreads; i++) { block = array + i * block_size; #pragma css task inout(block[block_size]) in(block_size) task_set(block, block_size); } #pragma css task in(array[array_size]) in(array_size) task_print(array, array_size); /*#pragma css sync*/ for (i = 0; i < nThreads; i++) { block = array + i * block_size; #pragma css task inout(block[block_size]) in(block_size) task_unset(block, block_size); } #pragma css task in(array[array_size]) in(array_size) task_print(array, array_size); #pragma css finish return 0; } /* main */
void task_yield() { disable_irq(); struct task_t *current_task = task_current(); struct list_node_t *next_task_it; struct task_t *next_task; if ( task_is_active(current_task) ) { next_task_it = current_task_it->next; } else { next_task_it = list_first(active_tasks); } next_task = (struct task_t *)next_task_it->data; task_print("task_yield:", current_task, next_task); if ( current_task == next_task ) { return; }; if ( next_task == 0 ) { print_buf("ERROR: next_task=0\n"); }; current_task_it = next_task_it; task_switch(¤t_task->sp, next_task->sp); }
void command (int c) { switch (c) { case '\n': case '\r': putchar (&debug, '\n'); eth_debug (ð, &debug); putchar (&debug, '\n'); break; case 't' & 037: printf (&debug, "\nFree memory: %u bytes\n\n", mem_available (&pool)); task_print (&debug, 0); task_print (&debug, (task_t*) stack_poll); task_print (&debug, (task_t*) eth.stack); putchar (&debug, '\n'); break; } }
void cmd_tasks(SerialDevice *io, int argc, char *argv[]) { serial_printf(io, "name: priority, mode, stack: used/size\r\n"); serial_printf(io, "static tasks:\r\n"); // static tasks Task_Object *task; int i; for (i = 0; i < Task_Object_count(); i++) { task = Task_Object_get(NULL, i); task_print(io, task); } // dymanmically allocated tasks serial_printf(io, "dynamic tasks:\r\n"); task = Task_Object_first(); while (task) { task_print(io, task); task = Task_Object_next(task); } }
void task_yield_from_irq(uint32 *sp) { struct list_node_t *next_task_it = current_task_it->next; struct task_t *next_task = (struct task_t *)next_task_it->data; struct task_t *current_task = (struct task_t *)current_task_it->data; current_task->sp = sp; current_task_it = next_task_it; task_print("task_yield_from_irq:", current_task, next_task); task_switch_no_save(next_task->sp); }
static int good(struct task *t) { int status; assert(t); status = task_print(t); assert(status == 0); return 0; }
void schedule_kill() { curr_task->state = TSK_Terminated; terminal_writestring("Killed task: \n"); task_print(curr_task); schd_task_del(curr_task); schedule(); curr_task = next_task; terminal_writestring("Resuming\n"); bochs_break(); resume_task(); }
void execute_print(char* command, ListT* tasks, TaskT** current_task) { assert(tasks != NULL); if (tasks->size == 0) { puts("No tasks."); } else { puts(""); int task_idx; for (task_idx = 0; task_idx < tasks->size; task_idx++) { printf("Task #%d: ", task_idx + 1); TaskT* task; task = list_obj_at_idx(tasks, task_idx); task_print(task); printf("\n", NULL); } } }
void print_current_task() { task_print(curr_task); }
void menu() { small_uint_t cmd; int full_duplex; printf(&debug, "Free memory: %d bytes\n", mem_available(&pool)); printf(&debug, "Ethernet: %s", eth_get_carrier(ð) ? "Cable OK" : "No cable"); if (eth_get_speed(ð, &full_duplex)) { printf(&debug, ", %s", full_duplex ? "Full Duplex" : "Half Duplex"); } printf(&debug, ", %u interrupts\n", eth.intr); printf(&debug, "Transmit: %ld packets, %ld collisions, %ld errors\n", eth.netif.out_packets, eth.netif.out_collisions, eth.netif.out_errors); printf(&debug, "Receive: %ld packets, %ld errors, %ld lost\n", eth.netif.in_packets, eth.netif.in_errors, eth.netif.in_discards); printf(&debug, "\n 1. Transmit 1 packet"); printf(&debug, "\n 2. Transmit 2 packets"); printf(&debug, "\n 3. Transmit 8 packets"); printf(&debug, "\n 4. Run send/receive test"); printf(&debug, "\n 5. Packet size: %d bytes", packet_size); printf(&debug, "\n 6. Local loopback: %s", local_loop ? "Enabled" : "Disabled"); puts(&debug, "\n\n"); for (;;) { /* Ввод команды. */ puts(&debug, "Command: "); while (peekchar (&debug) < 0) timer_delay(&timer, 50); cmd = getchar(&debug); putchar(&debug, '\n'); if (cmd == '\n' || cmd == '\r') break; if (cmd == '1') { send_packets(1); break; } if (cmd == '2') { send_packets(2); break; } if (cmd == '3') { send_packets(8); break; } if (cmd == '4') { run_test(); break; } if (cmd == '5') { try_again: printf(&debug, "Enter packet size (1-1518): "); packet_size = get_short(packet_size); if (packet_size <= 0 || packet_size > 1518) { printf(&debug, "Invalid value, try again."); goto try_again; } putchar(&debug, '\n'); data_pattern = mem_realloc(data_pattern, packet_size); if (!data_pattern) { printf(&debug, "No memory for data_pattern\n"); uos_halt(1); } int i; for (i = 0; i < packet_size; i++) data_pattern[i] = i; if (packet_size >= 6) memset(data_pattern, 0xFF, 6); if (packet_size >= 12) memcpy(data_pattern + 6, eth.netif.ethaddr, 6); break; } if (cmd == '6') { local_loop = !local_loop; eth_set_loop(ð, local_loop); break; } if (cmd == CTL('E')) { /* Регистры Ethernet. */ putchar(&debug, '\n'); eth_debug(ð, &debug); putchar(&debug, '\n'); continue; } if (cmd == CTL('T')) { /* Список задач uOS. */ printf(&debug, "\nFree memory: %u bytes\n\n", mem_available(&pool)); task_print(&debug, 0); task_print(&debug, (task_t*) stack_console); task_print(&debug, (task_t*) stack_test); task_print(&debug, (task_t*) eth.stack); putchar(&debug, '\n'); continue; } } }
static int mem_cmd (void *arg, Tcl_Interp *interp, int argc, unsigned char **argv) { stream_t *stream = arg; int n; putchar (stream, '\n'); printf (stream, "Free memory: %ld bytes\n", mem_available (&pool)); putchar (stream, '\n'); task_print (stream, 0); task_print (stream, (task_t*) stack_console); task_print (stream, (task_t*) stack_poll); task_print (stream, (task_t*) stack_telnet); for (n=0; n<MAXSESS; ++n) if (streamtab[n]) task_print (stream, (task_t*) tasktab[n]); task_print (stream, (task_t*) ip->stack); task_print (stream, (task_t*) eth->rstack); task_print (stream, (task_t*) eth->tstack); task_print (stream, (task_t*) hdlc->rstack); task_print (stream, (task_t*) hdlc->tstack); task_print (stream, (task_t*) uart.rstack); putchar (stream, '\n'); return TCL_OK; }