Beispiel #1
0
BOOL cg_mutex_delete(CgMutex *mutex)
{
	if (!mutex)
		return FALSE;

	cg_log_debug_l4("Entering...\n");

#if defined(WIN32) && !defined(ITRON)
	CloseHandle(mutex->mutexID);
#elif defined(BTRON)
	del_sem(mutex->mutexID);
#elif defined(ITRON)
	del_sem(mutex->mutexID);
#elif defined(TENGINE) && !defined(PROCESS_BASE)
	tk_del_sem(mutex->mutexID);
#elif defined(TENGINE) && defined(PROCESS_BASE)
	b_del_sem(mutex->mutexID);
#else
	pthread_mutex_destroy(&mutex->mutexID);
#endif
	free(mutex);

	cg_log_debug_l4("Leaving...\n");

	return TRUE;
}
Beispiel #2
0
/*
 * Delete high-speed lock
 */
EXPORT void DeleteLock( FastLock *lock )
{
	if ( lock->id > 0 ) {
		tk_del_sem(lock->id);
	}
	lock->id = 0;
}
Beispiel #3
0
bool mupnp_mutex_delete(mUpnpMutex *mutex)
{
	if (!mutex)
		return false;

	mupnp_log_debug_l4("Entering...\n");

#if defined(WIN32) && !defined(ITRON)
	CloseHandle(mutex->mutexID);
#elif defined(BTRON)
	del_sem(mutex->mutexID);
#elif defined(ITRON)
	del_sem(mutex->mutexID);
#elif defined(TENGINE) && !defined(PROCESS_BASE)
	tk_del_sem(mutex->mutexID);
#elif defined(TENGINE) && defined(PROCESS_BASE)
	b_del_sem(mutex->mutexID);
#else
	pthread_mutex_destroy(&mutex->mutexID);
#endif
	free(mutex);

	mupnp_log_debug_l4("Leaving...\n");

	return true;
}
Beispiel #4
0
void net_test(void)
{
	T_CSEM csem;
	T_CTSK ctsk;

	printf(" == net test == \n");

	net_conf(NET_CONF_EMULATOR, NET_CONF_DHCP);
	net_show();

	csem.maxsem = 100;
	csem.isemcnt = 0;
	csem.sematr = TA_TFIFO | TA_FIRST;
	semid = tk_cre_sem(&csem);
	semid2 = tk_cre_sem(&csem);

	bzero(&ctsk, sizeof ctsk);
	ctsk.tskatr = TA_HLNG | TA_RNG0;
	ctsk.task = server_task;
	ctsk.itskpri = 100;
	ctsk.stksz = 32 * 1024 * 2;
	server_tskid = tk_cre_tsk(&ctsk);
	DEBUG_PRINT(("start server task %d\n", server_tskid));
	tk_sta_tsk(server_tskid, 0);

	DEBUG_PRINT(("wait server semaphore\n"));
	tk_wai_sem(semid, 1, TMO_FEVR);

	bzero(&ctsk, sizeof ctsk);
	ctsk.tskatr = TA_HLNG | TA_RNG0;
	ctsk.task = client_task;
	ctsk.itskpri = 101;
	ctsk.stksz = 4 * 1024 * 2;
	client_tskid = tk_cre_tsk(&ctsk);
	DEBUG_PRINT(("start client task %d\n", client_tskid));
	tk_sta_tsk(client_tskid, 0);

	DEBUG_PRINT(("waiting for server and client semaphore\n"));
	tk_wai_sem(semid, 2, TMO_FEVR);

	printf(" == net test end == \n");

	tk_del_sem(semid);
	tk_del_sem(semid2);
}
Beispiel #5
0
void tkn_rw_destroy(krwlock_t *rw)
{
    LockTKN();

    if ( rw->semid != 0 ) {
        tk_del_sem(rw->semid);
        if ( rw->oldspl >= 0 ) {
            splx(rw->oldspl);
        }
    }

    rw->semid = 0;

    UnlockTKN();
}
/*
 * Finalization sequence of system management
 */
EXPORT ER finish_devmgr( void )
{
	ER	ercd;

	/* Unregister subsystem */
	ercd = tk_def_ssy(DEVICE_SVC, NULL);
#ifdef DEBUG
	if ( ercd < E_OK ) {
		extension_printf(("1. finish_devmgr -> tk_def_ssy ercd = %d\n", ercd));
	}
#endif

	/* Unregister device initial setting information */
	ercd = delIDev();
#ifdef DEBUG
	if ( ercd < E_OK ) {
		extension_printf(("2. finish_devmgr -> delIDev ercd = %d\n", ercd));
	}
#endif

	/* Finalization sequence of device input/output-related */
	ercd = finishDevIO();
#ifdef DEBUG
	if ( ercd < E_OK ) {
		extension_printf(("3. finish_devmgr -> finishDevIO ercd = %d\n", ercd));
	}
#endif

	/* Delete device registration information table */
	if ( DevCBtbl != NULL ) {
		Ifree(DevCBtbl);
		DevCBtbl = NULL;
	}

	/* Delete semaphore for device management synchronous control */
	if ( DevMgrSync > 0 ) {
		tk_del_sem(DevMgrSync);
		DevMgrSync = 0;
	}

	/* Delete lock for device management exclusive control */
	DeleteMLock(&DevMgrLock);

	return ercd;
}
Beispiel #7
0
 int FreeMutex(wolfSSL_Mutex* m)
 {
     tk_del_sem( m->id );
     return 0;
 }
Beispiel #8
0
static void test_tcp_server(void)
{
	int re;
	int sd;
	int reader = 0;
	char buf[5];
	struct sockaddr_in sa;
	struct sockaddr_in sa2;
	socklen_t sa_len;

	printf("[tcp(server)] start\n");

	sd = so_socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
	if ( sd < 0 ) {
		goto error;
	}
	DEBUG_PRINT(("server_task: so_socket = %d(%d, %d)\n", sd, MERCD(sd), SERCD(sd)));

	bzero(&sa, sizeof sa);
	sa.sin_family = AF_INET;
	sa.sin_addr.s_addr = htonl(INADDR_ANY);
	sa.sin_port = htons(12345);
	re = so_bind(sd, (struct sockaddr*)&sa, sizeof sa);
	DEBUG_PRINT(("server_task: so_bind = %d(%d, %d)\n", re, MERCD(re), SERCD(re)));
	if ( re < 0 ) {
		goto error;
	}

	re = so_listen(sd, 5);
	DEBUG_PRINT(("server_task: so_listen = %d(%d, %d)\n", re, MERCD(re), SERCD(re)));
	if ( re < 0 ) {
		goto error;
	}

	tk_sig_sem(semid, 1);
	DEBUG_PRINT(("server_task: server semaphore signaled 1\n"));

	reader = so_accept(sd, (struct sockaddr*)&sa2, &sa_len);
	DEBUG_PRINT(("server_task: so_accept = %d(%d, %d)\n", reader, MERCD(reader), SERCD(reader)));
	if ( reader < 0 ) {
		goto error;
	}

	wait_data(reader);

	bzero(buf, sizeof buf);
	re = so_sockatmark(reader);
	DEBUG_PRINT(("server_task: so_sockatmark = %d(%d, %d)\n", re, MERCD(re), SERCD(re)));
	if ( re < 0 ) {
		goto error;
	}
	re = so_read(reader, buf, 4);
	DEBUG_PRINT(("server_task: so_read = %d(%d, %d), buf = %s\n", re, MERCD(re), SERCD(re), buf));
	if ( re < 0 || memcmp(buf, "1234", 4) != 0 ) {
		goto error;
	}

	wait_data(reader);

	bzero(buf, sizeof buf);
	re = so_sockatmark(reader);
	DEBUG_PRINT(("server_task: so_sockatmark = %d(%d, %d)\n", re, MERCD(re), SERCD(re)));
	if ( re < 0 ) {
		goto error;
	}
	re = so_recv(reader, buf, 4, MSG_OOB);
	DEBUG_PRINT(("server_task: so_recv = %d(%d, %d), buf = %s\n", re, MERCD(re), SERCD(re), buf));
	if ( re < 0 || buf[0] != 'a' ) {
		goto error;
	}

	tk_sig_sem(semid2, 1);
	DEBUG_PRINT(("server_task: server semaphore for break signaled 2\n"));

	DEBUG_PRINT(("server_task: pre-accept for break\n"));
	re = so_accept(sd, (struct sockaddr*)&sa2, &sa_len);
	DEBUG_PRINT(("server_task: so_accept = %d(%d, %d)\n", re, MERCD(re), SERCD(re)));
	if ( re != EX_INTR ) {
		goto error;
	}

	so_close(reader);
	so_close(sd);

	printf("[tcp(server)] OK\n");
	return;

error:
	printf("[tcp(server)] FAILED\n");
	if ( sd > 0 ) {
		so_close(sd);
	}
	if ( reader > 0 ) {
		so_close(reader);
	}
	tk_del_sem(semid2);
	return;
}