static void* _sck_cli_run(void* p) { THREAD_START(p,_SCK*,s); if ( connect(s->h,(struct sockaddr *)&s->inf.adr,sizeof(struct sockaddr_in)) < 0) { if (s->fnc.eerr) s->fnc.eerr(s,NULL,SCK_ERR_CONNECT); if (s->fnc.disconnect) s->fnc.disconnect(s,NULL,0); THREAD_END(0); } if (s->fnc.connect) s->fnc.connect(s,s->arg.arg,0); while ( s->h >= 0) { THREAD_REQUEST(); if ( !_sck_recv(s) ) break; } THREAD_ONEXIT if (s->fnc.disconnect) s->fnc.disconnect(s,NULL,0); THREAD_END(0); }
static rtems_task bdbuf_test4_1_thread1(rtems_task_argument arg) { rtems_status_code rc; rtems_bdbuf_buffer *bd = NULL; /* * Step 1: * Call rtems_bdbuf_read(#N) in thread #1; */ rc = rtems_bdbuf_read(test_dd, TEST_BLK_NUM_N, &bd); if (rc != RTEMS_SUCCESSFUL) { TEST_FAILED(); } CONTINUE_MAIN(1); /* * Step 3: * Call rtems_bdbuf_sync(#N) */ rc = rtems_bdbuf_sync(bd); if (rc != RTEMS_SUCCESSFUL) { TEST_FAILED(); } CONTINUE_MAIN(1); THREAD_END(); }
static rtems_task bdbuf_test4_1_thread2(rtems_task_argument arg) { rtems_status_code rc; rtems_bdbuf_buffer *bd = NULL; WAIT_MAIN_SYNC(2); /* * Step 2: * In thread #2 call rtems_bdbuf_read(#N). * We will block on this call. */ rc = rtems_bdbuf_read(test_dd, TEST_BLK_NUM_N, &bd); if (rc != RTEMS_SUCCESSFUL) { TEST_FAILED(); } CONTINUE_MAIN(2); /* * Release buffer. */ rc = rtems_bdbuf_release(bd); if (rc != RTEMS_SUCCESSFUL) { TEST_FAILED(); } THREAD_END(); }
static rtems_task bdbuf_test3_3_thread1(rtems_task_argument arg) { rtems_status_code rc; rtems_bdbuf_buffer *bd = NULL; /* * Step 1: * Call rtems_bdbuf_read(#N) to get a buffer; */ rc = rtems_bdbuf_read(test_dd, TEST_BLK_NUM_N1, &bd); if (rc != RTEMS_SUCCESSFUL) { TEST_FAILED(); } CONTINUE_MAIN(1); /* * Step 4: * Call rtems_bdbuf_release(#N). */ rc = rtems_bdbuf_release(bd); if (rc != RTEMS_SUCCESSFUL) { TEST_FAILED(); } THREAD_END(); }
static rtems_task bdbuf_test3_3_thread3(rtems_task_argument arg) { rtems_status_code rc; rtems_bdbuf_buffer *bd = NULL; WAIT_MAIN_SYNC(3); /* * Step 3: * In thread #3 call read(#N3) */ rc = rtems_bdbuf_read(test_dd, TEST_BLK_NUM_N3, &bd); if (rc != RTEMS_SUCCESSFUL) { TEST_FAILED(); } printk("Thread #3 DEBLOCK\n"); CONTINUE_MAIN(3); rc = rtems_bdbuf_release(bd); if (rc != RTEMS_SUCCESSFUL) { TEST_FAILED(); } THREAD_END(); }
static rtems_task bdbuf_test3_1_thread2(rtems_task_argument arg) { rtems_status_code rc; rtems_bdbuf_buffer *bd = NULL; WAIT_MAIN_SYNC(2); /* * Step 4: * In thread #2 call read/get(#M) * [We ask for block number #M - there is no such entry in AVL, * and all the lists are empty (ready, lru, modified), as a result * this thread blocks on * rtems_bdbuf_wait(pool, &pool->waiting, &pool->wait_waiters)] */ rc = rtems_bdbuf_get(test_dev, TEST_BLK_NUM_M, &bd); if (rc != RTEMS_SUCCESSFUL) { TEST_FAILED(); } CONTINUE_MAIN(2); /* * Release buffer. */ rc = rtems_bdbuf_release_modified(bd); if (rc != RTEMS_SUCCESSFUL) { TEST_FAILED(); } THREAD_END(); }
static rtems_task bdbuf_test1_2_thread1(rtems_task_argument arg) { rtems_status_code rc; rtems_bdbuf_buffer *bd = NULL; /* * Step 1 - 3: * Try to read blk #N on thread #1 * We will block on this read and meanwhile * thread #2 will try to read the same block. * After blocking on read in thread #2, device * driver will notify about an error, and as the * result this call will return an error. */ rc = rtems_bdbuf_read(test_dd, TEST_BLK_NUM, &bd); if (rc != RTEMS_IO_ERROR || bd != NULL) { TEST_FAILED(); } CONTINUE_MAIN(1); THREAD_END(); }
static rtems_task bdbuf_test1_2_thread2(rtems_task_argument arg) { rtems_status_code rc; rtems_bdbuf_buffer *bd = NULL; WAIT_MAIN_SYNC(2); /* * Step 2: * Try to read block #N. Right now thread #1 is waiting * on data transfer operation, so we will block here as well. * * Step 4: * Due to the fact that thread #1 failed to read required block * number, bdbuf library should ask for re-read data again. * But main test task will agin tell device driver to return * RTEMS_IO_ERROR data transfer result. */ rc = rtems_bdbuf_read(test_dd, TEST_BLK_NUM, &bd); if (rc != RTEMS_IO_ERROR || bd != NULL) { TEST_FAILED(); } CONTINUE_MAIN(2); THREAD_END(); }
static rtems_task bdbuf_test3_2_thread2(rtems_task_argument arg) { rtems_status_code rc; rtems_bdbuf_buffer *bd = NULL; WAIT_MAIN_SYNC(2); /* * Step 2: * In thread #2 call get(#N2) */ rc = rtems_bdbuf_get(test_dd, TEST_BLK_NUM_N2, &bd); if (rc != RTEMS_SUCCESSFUL) { TEST_FAILED(); } printk("Thread #2 DEBLOCK\n"); CONTINUE_MAIN(2); rc = rtems_bdbuf_release_modified(bd); if (rc != RTEMS_SUCCESSFUL) { TEST_FAILED(); } THREAD_END(); }
static rtems_task bdbuf_test1_4_thread2(rtems_task_argument arg) { rtems_status_code rc; rtems_bdbuf_buffer *bd = NULL; WAIT_MAIN_SYNC(2); /* * Step 2: * Try to read block #N. Right now thread #1 is waiting * on data transfer operation, so we will block here as well. * * Step 5: * On step 4 thread #1 releases buffer and as the result * our read operation should finish with success. */ rc = rtems_bdbuf_read(test_dd, TEST_BLK_NUM, &bd); if (rc != RTEMS_SUCCESSFUL) { TEST_FAILED(); } CONTINUE_MAIN(2); /* * Step 6: * Release buffer returned on the previous step. */ rc = rtems_bdbuf_release(bd); if (rc != RTEMS_SUCCESSFUL) { TEST_FAILED(); } THREAD_END(); }
static rtems_task bdbuf_test1_4_thread1(rtems_task_argument arg) { rtems_status_code rc; rtems_bdbuf_buffer *bd = NULL; /* * Step 1 - 3: * Try to read blk #N on thread #1 * We will block on this read and meanwhile * thread #2 will try to read the same block. * After blocking on read in thread #2, device * driver will notify successful completion of * date transfer, and as the result this call * will return valid buffer. */ rc = rtems_bdbuf_read(test_dd, TEST_BLK_NUM, &bd); if (rc != RTEMS_SUCCESSFUL) { TEST_FAILED(); } CONTINUE_MAIN(1); /* * Step 4: * Release buffer returned on the previous step. */ rc = rtems_bdbuf_release(bd); if (rc != RTEMS_SUCCESSFUL) { TEST_FAILED(); } THREAD_END(); }
static void* _sck_srv_run(void* p) { THREAD_START(p,_SCK*,s); while ( s->h >= 0) { THREAD_REQUEST(); if (listen(s->h,1) < 0) { if (s->fnc.eerr) s->fnc.eerr(s,NULL,SCK_ERR_LISTEN); THREAD_END(0); } struct sockaddr_in adr; size_t sinsize = sizeof(struct sockaddr_in); HSCK hmc = accept(s->h,(struct sockaddr *)&adr,&sinsize); if (hmc < 0 ) { if (s->fnc.eerr) s->fnc.eerr(s,NULL,SCK_ERR_ACCEPT); continue; } _SCK* mc = sck_sc_new(s,hmc,htons(adr.sin_port)); strcpy(mc->inf.ip,inet_ntoa(adr.sin_addr)); if ( s->fnc.accept ) { if (!s->fnc.accept(mc,NULL,0) ) { sck_free(mc); continue; } } sck_run(mc); }//thread loop THREAD_ONEXIT if (s->fnc.disconnect) s->fnc.disconnect(s,NULL,0); THREAD_END(0); }
static rtems_task bdbuf_test3_1_thread1(rtems_task_argument arg) { rtems_status_code rc; rtems_bdbuf_buffer *bd = NULL; /* * Step 1: * Call rtems_bdbuf_get(#N) to get an empty block db; * [this call will remove a buffer from ready list and insert * it in AVL tree with ACCESS state. * Step 2: * Call release_modified(bd); * [Now we have one entry in modified list and it is still * in AVL tree with MODIFIED state] * Step 3: * Call read(#N) to get the same buffer. * [An entry is found in AVL tree, removed from modified list and * returned with state ACCESS_MODIFIED] */ rc = rtems_bdbuf_get(test_dev, TEST_BLK_NUM_N, &bd); if (rc != RTEMS_SUCCESSFUL) { TEST_FAILED(); } rc = rtems_bdbuf_release_modified(bd); if (rc != RTEMS_SUCCESSFUL) { TEST_FAILED(); } rc = rtems_bdbuf_read(test_dev, TEST_BLK_NUM_N, &bd); if (rc != RTEMS_SUCCESSFUL) { TEST_FAILED(); } CONTINUE_MAIN(1); /* Step 5: * Call rtems_bdbuf_release(#N). * As the result buffer will be used by bdbuf to get * buffer #M for thread #2. */ rc = rtems_bdbuf_release(bd); if (rc != RTEMS_SUCCESSFUL) { TEST_FAILED(); } THREAD_END(); }
/** run_internal() function, has different * return code etc. on different platform */ THREAD_INITFUNCTION(run_internal, arg) { CThread *pThread = (CThread *) arg; pThread->Run(); // Fixme: this should be done after THREAD_END(), // but we can't do anything after this; therefore // we add a little delay in IsRunning() pThread->m_isRunning = false; THREAD_END(pThread->m_SyncHandle); }
static void* _sck_sc_run(void* p) { THREAD_START(p,_SCK*,s); while ( s->h >= 0) { THREAD_REQUEST(); if ( !_sck_recv(s) ) break; } THREAD_ONEXIT if (s->fnc.disconnect) s->fnc.disconnect(s,NULL,0); THREAD_END(0); }
static rtems_task bdbuf_test1_3_thread2(rtems_task_argument arg) { rtems_status_code rc; rtems_bdbuf_buffer *bd = NULL; WAIT_MAIN_SYNC(2); /* * Step 2: * Try to read block #N. Right now thread #1 is waiting * on data transfer operation, so we will block here as well. * * Step 4-5: * Due to the fact that thread #1 failed to read required block * number, bdbuf library should ask for re-read data again. * Time time main task will tell driver to report success. */ rc = rtems_bdbuf_read(test_dd, TEST_BLK_NUM, &bd); if (rc != RTEMS_SUCCESSFUL || bd == NULL) { TEST_FAILED(); } CONTINUE_MAIN(2); /* * Step 6: * Release buffer. */ rc = rtems_bdbuf_release(bd); if (rc != RTEMS_SUCCESSFUL) { TEST_FAILED(); } THREAD_END(); }