예제 #1
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();
}
예제 #2
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();
}