Exemple #1
0
STATUS wdDelete(WDOG_ID wdog_id)
{
	struct wind_wd *wd;
	struct service svc;
	int ret = OK;

	COPPERPLATE_PROTECT(svc);

	/*
	 * XXX: we don't actually have to protect find_wd_from_id()
	 * since it can't be cancelled while holding a lock and does
	 * not change the system state, but the code looks better when
	 * we do so; besides, this small overhead only hits the error
	 * path.
	 */
	wd = find_wd_from_id(wdog_id);
	if (wd == NULL)
		goto objid_error;

	ret = timerobj_destroy(&wd->tmobj);
	if (ret) {
	objid_error:
		errno = S_objLib_OBJ_ID_ERROR;
		ret = ERROR;
		goto out;
	}

	wd->magic = ~wd_magic;
	pvfree(wd);
out:
	COPPERPLATE_UNPROTECT(svc);

	return ret;
}
Exemple #2
0
WDOG_ID wdCreate(void)
{
	struct wind_wd *wd;
	struct service svc;
	int ret;

	COPPERPLATE_PROTECT(svc);

	wd = pvmalloc(sizeof(*wd));
	if (wd == NULL)
		goto fail;

	ret = timerobj_init(&wd->tmobj);
	if (ret) {
		pvfree(wd);
	fail:
		errno = S_memLib_NOT_ENOUGH_MEMORY;
		wd = NULL;
		goto out;
	}

	wd->magic = wd_magic;
out:
	COPPERPLATE_UNPROTECT(svc);

	return (WDOG_ID)wd;
}
Exemple #3
0
static u_long start_evtimer(u_long events,
			    struct itimerspec *it, u_long *tmid_r)
{
	void (*handler)(struct timerobj *tmobj);
	struct psos_task *current;
	struct psos_tm *tm;
	int ret;

	tm = pvmalloc(sizeof(*tm));
	if (tm == NULL)
		return ERR_NOTIMERS;

	pvholder_init(&tm->link);
	tm->events = events;
	tm->magic = tm_magic;

	current = get_psos_task_or_self(0, &ret);
	if (current == NULL) {
		pvfree(tm);
		return ret;
	}

	tm->tid = mainheap_ref(current, u_long);
	pvlist_append(&tm->link, &current->timer_list);
	put_psos_task(current);

	*tmid_r = (u_long)tm;

	ret = timerobj_init(&tm->tmobj);
	if (ret) {
	fail:
		pvlist_remove(&tm->link);
		pvfree(tm);
		return ERR_NOTIMERS;
	}

	handler = post_event_periodic;
	if (it->it_interval.tv_sec == 0 &&
	    it->it_interval.tv_nsec == 0)
		handler = post_event_once;

	ret = timerobj_start(&tm->tmobj, handler, it);
	if (ret)
		goto fail;

	return SUCCESS;
}
Exemple #4
0
static void delete_timer(struct psos_tm *tm)
{
	struct service svc;

	COPPERPLATE_PROTECT(svc);
	timerobj_destroy(&tm->tmobj);
	pvlist_remove(&tm->link);
	pvfree(tm);
	COPPERPLATE_UNPROTECT(svc);
}
Exemple #5
0
void traceobj_destroy(struct traceobj *trobj)
{
	pvfree(trobj->marks);
	__RT(pthread_mutex_destroy(&trobj->lock));
}