rem: t = spawn_thread(port_test_thread_func, "port_test", THREAD_MEDIUM_PRIORITY, NULL);
add: t = spawn_thread(port_test_thread_func, "port_test", B_NORMAL_PRIORITY, NULL);
context: static void port_test(void){	char testdata[5];	thread_id t;	int res;	int32 dummy;	int32 dummy2;	strcpy(testdata, "abcd");	printf("porttest: port_create()\n");	test_p1 = sys_port_create(1,    "test port #1");	test_p2 = sys_port_create(10,   "test port #2");	test_p3 = sys_port_create(1024, "test port #3");	test_p4 = sys_port_create(1024, "test port #4");	printf("porttest: port_find()\n");	printf("'test port #1' has id %d (should be %d)\n", sys_port_find("test port #1"), test_p1);	printf("porttest: port_write() on 1, 2 and 3\n");	sys_port_write(test_p1, 1, &testdata, sizeof(testdata));	sys_port_write(test_p2, 666, &testdata, sizeof(testdata));	sys_port_write(test_p3, 999, &testdata, sizeof(testdata));	printf("porttest: port_count(test_p1) = %d\n", sys_port_count(test_p1));	printf("porttest: port_write() on 1 with timeout of 1 sec (blocks 1 sec)\n");	sys_port_write_etc(test_p1, 1, &testdata, sizeof(testdata), B_TIMEOUT, 1000000);	printf("porttest: port_write() on 2 with timeout of 1 sec (wont block)\n");	res = sys_port_write_etc(test_p2, 777, &testdata, sizeof(testdata), B_TIMEOUT, 1000000);	printf("porttest: res=%d, %s\n", res, res == 0 ? "ok" : "BAD");	printf("porttest: port_read() on empty port 4 with timeout of 1 sec (blocks 1 sec)\n");	res = sys_port_read_etc(test_p4, &dummy, &dummy2, sizeof(dummy2), B_TIMEOUT, 1000000);	printf("porttest: res=%d, %s\n", res, res == ETIMEDOUT ? "ok" : "BAD");	printf("porttest: spawning thread for port 1\n");	t = spawn_thread(port_test_thread_func, "port_test", THREAD_MEDIUM_PRIORITY, NULL);	// resume thread	resume_thread(t);	printf("porttest: write\n");	sys_port_write(test_p1, 1, &testdata, sizeof(testdata));	// now we can write more (no blocking)	printf("porttest: write #2\n");	sys_port_write(test_p1, 2, &testdata, sizeof(testdata));	printf("porttest: write #3\n");	sys_port_write(test_p1, 3, &testdata, sizeof(testdata));	printf("porttest: waiting on spawned thread\n");	sys_wait_on_thread(t, NULL);	printf("porttest: close p1\n");	sys_port_close(test_p2);	printf("porttest: attempt write p1 after close\n");	res = sys_port_write(test_p2, 4, &testdata, sizeof(testdata));	printf("porttest: port_write ret %s (should give Bad port id)\n", strerror(res));	printf("porttest: testing delete p2\n");	sys_port_delete(test_p2);	printf("porttest: end test main thread\n");}