[SOLVED] CS /* Ensures that a high-priority thread really preempts.

$25

File Name: CS_/*_Ensures_that_a_high-priority_thread_really_preempts..zip
File Size: 546.36 KB

5/5 - (1 vote)

/* Ensures that a high-priority thread really preempts.

Based on a test originally submitted for Stanfords CS 140 in
winter 1999 by by Matt Franklin
, Greg Hutchins
, Yu Ping Hu .
Modified by arens. */

#include
#include tests/threads/tests.h
#include threads/init.h
#include threads/thread.h

static thread_func simple_thread_func;

void
test_priority_preempt (void)
{
/* This test does not work with the MLFQS. */
ASSERT (!thread_mlfqs);

/* Make sure our priority is the default. */
ASSERT (thread_get_priority () == PRI_DEFAULT);

thread_create (high-priority, PRI_DEFAULT + 1, simple_thread_func, NULL);
msg (The high-priority thread should have already completed.);
}

static void
simple_thread_func (void *aux UNUSED)
{
int i;

for (i = 0; i < 5; i++) {msg (“Thread %s iteration %d”, thread_name (), i);thread_yield ();}msg (“Thread %s done!”, thread_name ());}

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] CS /* Ensures that a high-priority thread really preempts.
$25