static inline int block_ser_if_block_track_lock_component_take(spdid_t spdid,
        ul_t lock_id,
        u32_t thd_id)
{
    int ret = 0;
    struct track_block tb;	// track on stack

    do {
        if (sched_component_take(cos_spd_id()))
            BUG();
    } while (0);

    if (unlikely(!tracking_block_list[spdid].next)) {
        INIT_LIST(&tracking_block_list[spdid], next, prev);
    }
    INIT_LIST(&tb, next, prev);
    tb.lock_id = lock_id;
    ADD_LIST(&tracking_block_list[spdid], &tb, next, prev);

    do {
        if (sched_component_release(cos_spd_id()))
            BUG();
    } while (0);

    ret = lock_component_take(spdid, lock_id, thd_id);

    do {
        if (sched_component_take(cos_spd_id()))
            BUG();
    } while (0);

    REM_LIST(&tb, next, prev);

    do {
        if (sched_component_release(cos_spd_id()))
            BUG();
    } while (0);

    return ret;
}
Beispiel #2
0
int __sg_sched_component_release(spdid_t spdid)
{
	/* printc("ser: sched_component_release (thd %d)\n", cos_get_thd_id()); */
	int ret;
#ifdef LOG_MONITOR
	evt_enqueue(cos_get_thd_id(), spdid, cos_spd_id(), 0, 0, EVT_SINV);
#endif
	ret = sched_component_release(spdid);
#ifdef LOG_MONITOR
	evt_enqueue(cos_get_thd_id(), cos_spd_id(), spdid, 0, 0, EVT_SRET);
#endif
	return ret;
}
static inline void block_ser_if_client_fault_notification(int spdid)
{
    struct track_block *tb;

    do {
        if (sched_component_take(cos_spd_id()))
            BUG();
    } while (0);

    if (!tracking_block_list[spdid].next)
        goto done;
    if (EMPTY_LIST(&tracking_block_list[spdid], next, prev))
        goto done;

    for (tb = FIRST_LIST(&tracking_block_list[spdid], next, prev);
            tb != &tracking_block_list[spdid];
            tb = FIRST_LIST(tb, next, prev)) {

        do {
            if (sched_component_release(cos_spd_id()))
                BUG();
        } while (0);

        lock_component_release(spdid, tb->lock_id);

        do {
            if (sched_component_take(cos_spd_id()))
                BUG();
        } while (0);
    }

done:
    do {
        if (sched_component_release(cos_spd_id()))
            BUG();
    } while (0);

    return;
}
Beispiel #4
0
void lock_component_free(spdid_t spd, unsigned long lock_id)
{
	struct meta_lock *l;
	spdid_t spdid = cos_spd_id();

	if (sched_component_take(spdid)) return;
	l = lock_find(lock_id, spd);
	if (sched_component_release(spdid)) return;

	if (l) lock_free(l);

	return;
}
Beispiel #5
0
int __sg_sched_component_release(spdid_t spdid)
{
	/* printc("ser: sched_component_release (thd %d)\n", cos_get_thd_id()); */
	int ret;
#ifdef LOG_MONITOR
	monevt_enqueue(cos_spd_id(), 14, 0);
#endif
	ret = sched_component_release(spdid);
#ifdef LOG_MONITOR
	monevt_enqueue(0, 14, 0);
#endif
	return ret;
}
static void start_timer_thread(void)
{
	spdid_t spdid = cos_spd_id();
	unsigned int tick_freq;

	INIT_LIST(&events, next, prev);
	events.thread_id = 0;
	INIT_LIST(&periodic, next, prev);
	periodic.thread_id = 0;

	cos_vect_init_static(&thd_evts);
	cos_vect_init_static(&thd_periodic);

	sched_timeout_thd(spdid);
	tick_freq = sched_tick_freq();
	assert(tick_freq == 100);
	ticks = sched_timestamp();
	/* currently timeouts are expressed in ticks, so we don't need this */
//	usec_per_tick = USEC_PER_SEC/tick_freq;
	cyc_per_tick = sched_cyc_per_tick();
	//	printc("cyc_per_tick = %lld\n", cyc_per_tick);

	/* When the system boots, we have no pending waits */
	assert(EMPTY_LIST(&events, next, prev));
	sched_block(spdid, 0);
	/* Wait for events, then act on expired events.  Loop. */
	while (1) {
		event_time_t next_wakeup;

		cos_mpd_update(); /* update mpd config given this
				   * thread is now in this component
				   * (no dependency if we are in the
				   * same protection domain as the
				   * scheduler) */
		ticks = sched_timestamp();
		if (sched_component_take(spdid)) {
			prints("fprr: scheduler lock failed!!!");
			BUG();
		}
		event_expiration(ticks);
		next_wakeup = next_event_time();

		/* Are there no pending events??? */
		if (TIMER_NO_EVENTS == next_wakeup) {
			if (sched_component_release(spdid)) {
				prints("fprr: scheduler lock release failed!!!");
				BUG();
			}

			sched_block(spdid, 0);
		} else {
			unsigned int wakeup;

			assert(next_wakeup > ticks);
			wakeup = (unsigned int)(next_wakeup - ticks);
			if (sched_component_release(spdid)) {
				prints("fprr: scheduler lock release failed!!!");
				BUG();
			}
			sched_timeout(spdid, wakeup);
		}
	}
}