Ejemplo n.º 1
0
static int sv_test_2_s_1(void *arg) 
{
	int i;
	sv_t *sv = (sv_t *)arg;

	down(&monitor);
	for(i = 0; i < 3; i++) {
		printk("sv_test_2_s_1: waking one thread.\n");
		sv_signal(sv);
		down(&sem);
	}

	printk("sv_test_2_s_1: signaling and broadcasting again.  Nothing should happen.\n");
	sv_signal(sv);
	sv_broadcast(sv);
	sv_signal(sv);
	sv_broadcast(sv);

	printk("sv_test_2_s_1: talkbacking.\n");
	up(&talkback);
	up(&monitor);
	return 0;
}
Ejemplo n.º 2
0
static int sv_test_1_s(void *arg) 
{
	printk("sv_test_1_s: waiting for semaphore.\n");
	down(&sem);
	printk("sv_test_1_s: semaphore acquired.  Acquiring spinlock.\n");
	spin_lock((spinlock_t*)arg);
	printk("sv_test_1_s: spinlock acquired.  sv_signaling.\n");
	sv_signal(&sv);
	printk("sv_test_1_s: talkback.\n");
	up(&talkback);
	printk("sv_test_1_s: exiting.\n");
	return 0;

}
Ejemplo n.º 3
0
/*
 * hub_piomap_free destroys a caddr_t-to-xtalk pio mapping and frees
 * any associated mapping resources.
 *
 * If this * piomap was handled with a small window, or if it was handled
 * in a big window that's still in use by someone else, then there's
 * nothing to do.  On the other hand, if this mapping was handled
 * with a big window, AND if we were the final user of that mapping,
 * then destroy the mapping.
 */
void
hub_piomap_free(hub_piomap_t hub_piomap)
{
    devfs_handle_t hubv;
    hubinfo_t hubinfo;
    nasid_t nasid;
    int s;

    /*
     * Small windows are permanently mapped to corresponding widgets,
     * so there're no resources to free.
     */
    if (!(hub_piomap->hpio_flags & HUB_PIOMAP_IS_BIGWINDOW))
        return;

    ASSERT(hub_piomap->hpio_flags & HUB_PIOMAP_IS_VALID);
    ASSERT(hub_piomap->hpio_holdcnt > 0);

    hubv = hub_piomap->hpio_hub;
    hubinfo_get(hubv, &hubinfo);
    nasid = hubinfo->h_nasid;

    s = mutex_spinlock(&hubinfo->h_bwlock);

    /*
     * If this is the last hold on this mapping, free it.
     */
    if (--hub_piomap->hpio_holdcnt == 0) {
        IIO_ITTE_DISABLE(nasid, hub_piomap->hpio_bigwin_num );

        if (hub_piomap->hpio_flags & HUB_PIOMAP_IS_FIXED) {
            hub_piomap->hpio_flags &= ~(HUB_PIOMAP_IS_VALID | HUB_PIOMAP_IS_FIXED);
            hubinfo->h_num_big_window_fixed--;
            ASSERT(hubinfo->h_num_big_window_fixed >= 0);
        } else
            hub_piomap->hpio_flags &= ~HUB_PIOMAP_IS_VALID;

        (void)sv_signal(&hubinfo->h_bwwait);
    }

    mutex_spinunlock(&hubinfo->h_bwlock, s);
}
Ejemplo n.º 4
0
static int sv_test_2_s(void *arg) 
{
	int i;
	sv_t *sv = (sv_t *)arg;

	down(&monitor);
	for(i = 0; i < 3; i++) {
		printk("sv_test_2_s: waking one thread (should be %d.)\n", i);
		sv_signal(sv);
		down(&sem);
	}

	printk("sv_test_3_s: waking remaining threads with broadcast.\n");
	sv_broadcast(sv);
	for(; i < 10; i++)
		down(&sem);

	printk("sv_test_3_s: sending talkback.\n");
	up(&talkback);

	printk("sv_test_3_s: exiting.\n");
	up(&monitor);
	return 0;
}