void bdbuf_test3_1_main() { bdbuf_test_msg msg; TEST_START("Test 3.1"); START_THREAD(1, bdbuf_test3_1_thread1); START_THREAD(2, bdbuf_test3_1_thread2); /* * Step 1-3: * Wait for sync from thread #1. * Thread #1 switch a buffer for #N into ACCESS_MODIFIED state. */ WAIT_THREAD_SYNC(1); TEST_CHECK_RESULT("3"); /* * Step 4: * Thread #2 calls get() function and blocks * (there no buffers available in bdbuf library). */ CONTINUE_THREAD(2); /* Make sure thread #2 managed to block on the buffer. */ CHECK_THREAD_BLOCKED(2); /* * Step 6: * Thread #1 release buffer. */ CONTINUE_THREAD(1); /* * Buffer released in thread #1 was in MODIFIED state, so * there will be a request for disk write */ WAIT_DRV_MSG_WR(&msg); SEND_DRV_MSG(0, 0, RTEMS_SUCCESSFUL, 0); /* * Check that thread #2 unblocked after this. */ WAIT_THREAD_SYNC(2); TEST_CHECK_RESULT("5"); /* * Release buffer in thread #2 */ CONTINUE_THREAD(2); /* * Buffer released in thread #2 switched to MODIFIED state, so * there will be a request for disk write */ WAIT_DRV_MSG_WR(&msg); SEND_DRV_MSG(0, 0, RTEMS_SUCCESSFUL, 0); TEST_END(); }
void bdbuf_test4_1_main() { bdbuf_test_msg msg; TEST_START("Test 4.1"); START_THREAD(1, bdbuf_test4_1_thread1); START_THREAD(2, bdbuf_test4_1_thread2); /* * Step 1: * Call rtems_bdbuf_read(#N) in thread #1. * Wait for read request in disk driver. */ WAIT_DRV_MSG(&msg); SEND_DRV_MSG(0, 0, RTEMS_SUCCESSFUL, 0); /* Wait for return from rtems_bdbuf_read(#N) function. */ WAIT_THREAD_SYNC(1); /* * Step 2: * Call rtems_bdbuf_read(#N) in thread #2. */ CONTINUE_THREAD(2); /* Make sure that thread #2 blocks */ CHECK_THREAD_BLOCKED(2); TEST_CHECK_RESULT("2"); /* * Step 3: * Call rtems_bdbuf_sync (#N) in thread #1. */ CONTINUE_THREAD(1); /* * Setp 4: * Wait for Write request to device driver. */ WAIT_DRV_MSG_WR(&msg); /* Check that both threads are blocked right now */ CHECK_THREAD_BLOCKED(1); CHECK_THREAD_BLOCKED(2); /* Send Write complete notification */ SEND_DRV_MSG(0, 0, RTEMS_SUCCESSFUL, 0); /* * Step 5: * Check that rtems_bdbuf_sync(#N) call is unlocked. */ WAIT_THREAD_SYNC(1); TEST_CHECK_RESULT("5"); /* * Step 6: * Check that rtems_bdbuf_read(#N) call in thread #2 is unlocked. */ WAIT_THREAD_SYNC(2); /* * Step 7: * Release buffer in thread #2 */ CONTINUE_THREAD(2); /* * Exit from thread #1. */ CONTINUE_THREAD(1); TEST_END(); }
void bdbuf_test3_2_main() { bdbuf_test_msg msg; TEST_START("Test 3.2"); /* * Create working threads. */ SET_THREAD_PRIORITY(2, LOW); SET_THREAD_PRIORITY(3, HIGH); START_THREAD(1, bdbuf_test3_2_thread1); START_THREAD(2, bdbuf_test3_2_thread2); START_THREAD(3, bdbuf_test3_2_thread3); /* * Start thread #1: it will read buffer #N1. * Driver is asked to read this buffer. */ WAIT_DRV_MSG(&msg); SEND_DRV_MSG(0, 0, RTEMS_SUCCESSFUL, 0); WAIT_THREAD_SYNC(1); /* * Block thread #2 and thread #3 on get buffers #N1 and #N2 * correspondingly. */ CONTINUE_THREAD(2); CONTINUE_THREAD(3); /* Make sure threads managed to block on the buffers get. */ CHECK_THREAD_BLOCKED(2); CHECK_THREAD_BLOCKED(3); /* * Step 4: * Thread #1 release buffer. */ CONTINUE_THREAD(1); /* * Check that thread #2 unblocked after this. */ WAIT_THREAD_SYNC(2); TEST_CHECK_RESULT("5"); CHECK_THREAD_BLOCKED(3); /* Release buffer in thread #2 */ CONTINUE_THREAD(2); /* wait for driver message to flush it onto a disk */ WAIT_DRV_MSG_WR(&msg); SEND_DRV_MSG(0, 0, RTEMS_SUCCESSFUL, 0); /* Wait for thread #3 to be unblocked */ WAIT_THREAD_SYNC(3); /* Release buffer in thread #3 */ CONTINUE_THREAD(3); /* wait for driver message to flush it onto a disk */ WAIT_DRV_MSG_WR(&msg); SEND_DRV_MSG(0, 0, RTEMS_SUCCESSFUL, 0); TEST_END(); }