<commit_before>/**
 * \file
 * \brief Waitset and low-level event handling mechanism
 *
 * A "wait set" is a collection of channels to wait on, much like an
 * FDSET in POSIX. There should be a default, static wait set for each
 * dispatcher. Threads which wait for events specify the wait set they
 * are waiting on.
 */

/*
 * Copyright (c) 2009, 2010, 2011, ETH Zurich.
 * All rights reserved.
 *
 * This file is distributed under the terms in the attached LICENSE file.
 * If you do not find this file, copies can be found by writing to:
 * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
 */

#include <barrelfish/barrelfish.h>
#include <barrelfish/waitset.h>
#include <barrelfish/threads.h>
#include <barrelfish/dispatch.h>
#include <threads.h>
#include "waitset_chan.h"

#ifdef CONFIG_INTERCONNECT_DRIVER_UMP
#  include <barrelfish/ump_endpoint.h>
#endif

#if defined(__x86_64__) || defined(__i386__)
#include <arch/x86/barrelfish_kpi/asm_inlines_arch.h>
static inline cycles_t cyclecount(void)
{
    return rdtsc();
}
#else
static inline cycles_t cyclecount(void)
{
    USER_PANIC("called on non-x86 architecture. why are we polling?");
    return 0;
}
#endif

// FIXME: bogus default value. need to measure this at boot time
#define WAITSET_POLL_CYCLES_DEFAULT 20000 

/// Maximum number of cycles to spend polling channels before yielding CPU
cycles_t waitset_poll_cycles = WAITSET_POLL_CYCLES_DEFAULT;

/**
 * \brief Initialise a new waitset
 */
void waitset_init(struct waitset *ws)
{
    assert(ws != NULL);
    ws->pending = ws->polled = ws->idle = NULL;<commit_msg>Revert the change to WAITSET_POLL_CYCLES_DEFAULT. I initially tuned this value to reduce the variation in my benchmarks and pushed it into the repo by accident :-/. Interestingly, this change broke the vmkit testcase.<commit_after>/**
 * \file
 * \brief Waitset and low-level event handling mechanism
 *
 * A "wait set" is a collection of channels to wait on, much like an
 * FDSET in POSIX. There should be a default, static wait set for each
 * dispatcher. Threads which wait for events specify the wait set they
 * are waiting on.
 */

/*
 * Copyright (c) 2009, 2010, 2011, ETH Zurich.
 * All rights reserved.
 *
 * This file is distributed under the terms in the attached LICENSE file.
 * If you do not find this file, copies can be found by writing to:
 * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
 */

#include <barrelfish/barrelfish.h>
#include <barrelfish/waitset.h>
#include <barrelfish/threads.h>
#include <barrelfish/dispatch.h>
#include <threads.h>
#include "waitset_chan.h"

#ifdef CONFIG_INTERCONNECT_DRIVER_UMP
#  include <barrelfish/ump_endpoint.h>
#endif

#if defined(__x86_64__) || defined(__i386__)
#include <arch/x86/barrelfish_kpi/asm_inlines_arch.h>
static inline cycles_t cyclecount(void)
{
    return rdtsc();
}
#else
static inline cycles_t cyclecount(void)
{
    USER_PANIC("called on non-x86 architecture. why are we polling?");
    return 0;
}
#endif

// FIXME: bogus default value. need to measure this at boot time
#define WAITSET_POLL_CYCLES_DEFAULT 2000 

/// Maximum number of cycles to spend polling channels before yielding CPU
cycles_t waitset_poll_cycles = WAITSET_POLL_CYCLES_DEFAULT;

/**
 * \brief Initialise a new waitset
 */
void waitset_init(struct waitset *ws)
{
    assert(ws != NULL);
    ws->pending = ws->polled = ws->idle = NULL;
{'fraction_non_alphanumeric': 0.0951683748169839, 'fraction_numerical': 0.019619326500732063, 'mean_word_length': 4.223241590214068, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1171610', 'n_tokens_mistral': 1188, 'n_tokens_neox': 1108, 'n_words': 396}