Beispiel #1
0
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();
}
Beispiel #2
0
void
bdbuf_test3_3_main()
{
    bdbuf_test_msg msg;

    TEST_START("Test 3.3");

    /*
     * Create working threads.
     */
    SET_THREAD_PRIORITY(2, LOW);
    SET_THREAD_PRIORITY(3, HIGH);
    START_THREAD(1, bdbuf_test3_3_thread1);
    START_THREAD(2, bdbuf_test3_3_thread2);
    START_THREAD(3, bdbuf_test3_3_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 #N2 and #N3
     * correspondingly (bdbuf librbary has no buffers available).
     */
    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);

    /* Wait for read request in the driver (for thread #2) */
    WAIT_DRV_MSG(&msg);
    SEND_DRV_MSG(0, 0, RTEMS_SUCCESSFUL, 0);

    /* Check that there is no read request for another block */
    CHECK_NO_DRV_MSG();

    /*
     * Check that thread #2 unblocked after this.
     */
    WAIT_THREAD_SYNC(2);
    TEST_CHECK_RESULT("5");

    /* Thread #3 is still in blocked state */
    CHECK_THREAD_BLOCKED(3);

    /* Release buffer in thread #2 */
    CONTINUE_THREAD(2);

    /* Wait for read request in the driver (for thread #3) */
    WAIT_DRV_MSG(&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);

    CHECK_NO_DRV_MSG();

    TEST_END();
}
Beispiel #3
0
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();
}
Beispiel #4
0
void
bdbuf_test1_2_main()
{
    bdbuf_test_msg msg;

    TEST_START("Test 1.2");

    START_THREAD(1, bdbuf_test1_2_thread1);
    START_THREAD(2, bdbuf_test1_2_thread2);

    /*
     * Step 1:
     * Thread #1 calls rtems_bdbuf_read() and we block
     * this thread on data transfer operation.
     */
    WAIT_DRV_MSG(&msg);

    /*
     * Step 2:
     * Thread #2 calls rtems_bdbuf_read() for the same 
     * block number, as the result it shall block waiting
     * on buffer state change.
     */
    CONTINUE_THREAD(2);

    /* Make sure thread #2 managed to block on the buffer. */
    CHECK_THREAD_BLOCKED(2);

    /*
     * Step 3:
     * Unblock thread #1 by reporting data transfer result.
     */
    SEND_DRV_MSG(0, 0, RTEMS_IO_ERROR, EFAULT);

    /*
     * Wait for sync from thread #1.
     */
    WAIT_THREAD_SYNC(1);
    CONTINUE_THREAD(1);
    TEST_CHECK_RESULT("3");

    /*
     * Step 4:
     * For thread #2 bdbuf shall try to re-read data.
     * As the result we will get read call to device driver.
     */
    WAIT_DRV_MSG(&msg);
    
    /* Check that thread #2 is still blocked */
    CHECK_THREAD_BLOCKED(2);
    /*
     * Step 5:
     * Report an error again from the driver.
     */
    SEND_DRV_MSG(0, 0, RTEMS_IO_ERROR, EFAULT);

    /*
     * Wait for sync from thread #2.
     */
    WAIT_THREAD_SYNC(2);
    CONTINUE_THREAD(2);
    TEST_CHECK_RESULT("5");

    TEST_END();
}
Beispiel #5
0
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();
}
Beispiel #6
0
void
bdbuf_test1_4_main()
{
    bdbuf_test_msg msg;

    TEST_START("Test 1.4");

    START_THREAD(1, bdbuf_test1_4_thread1);
    START_THREAD(2, bdbuf_test1_4_thread2);

    /*
     * Step 1:
     * Thread #1 calls rtems_bdbuf_read() and we block
     * this thread on data transfer operation.
     */
    WAIT_DRV_MSG(&msg);

    /*
     * Step 2:
     * Thread #2 calls rtems_bdbuf_read() for the same 
     * block number, as the result it shall block waiting
     * on buffer state change (waiting on TRANSFER state).
     */
    CONTINUE_THREAD(2);

    /* Make sure threads #1 and #2 managed blocked on the buffer. */
    CHECK_THREAD_BLOCKED(1);
    CHECK_THREAD_BLOCKED(2);

    /*
     * Step 3:
     * Unblock thread #1 by reporting successful data transfer result.
     */
    SEND_DRV_MSG(0, 0, RTEMS_SUCCESSFUL, 0);

    /*
     * Wait for sync from thread #1.
     */
    WAIT_THREAD_SYNC(1);
    TEST_CHECK_RESULT("3");

    /* 
     * Check that thread #2 is still blocked.
     */
    CHECK_THREAD_BLOCKED(2);

    /*
     * Step 4:
     * Thread #1 releases buffer with bdbuf_release() call.
     */
    CONTINUE_THREAD(1);

    /*
     * Step 5:
     * On buffer release operation, we should have unblock
     * of thread #2 that is wating on read buffer operation.
     */
    WAIT_THREAD_SYNC(2);
    TEST_CHECK_RESULT("5");

    /*
     * Step 6:
     * Thread #2 release buffer.
     */
    CONTINUE_THREAD(2);

    TEST_END();
}