Example #1
0
extern "C" int main(int argc, char *argv[]) {
	SceUID msgpipe = sceKernelCreateMsgPipe("delete", PSP_MEMORY_PARTITION_USER, 0, 0x100, NULL);

	testDelete("Normal", msgpipe);
	testDelete("NULL", 0);
	testDelete("Invalid", 0xDEADBEEF);
	testDelete("Deleted", msgpipe);

	{
		msgpipe = sceKernelCreateMsgPipe("delete", PSP_MEMORY_PARTITION_USER, 0, 0x100, NULL);
		MsgPipeReceiveWaitThread wait_r1("receiving thread 1", msgpipe, NO_TIMEOUT);
		MsgPipeReceiveWaitThread wait_r2("receiving thread 2", msgpipe, 10000);
		checkpoint("With receiving threads: %08x", sceKernelDeleteMsgPipe(msgpipe));
	}

	{
		msgpipe = sceKernelCreateMsgPipe("delete", PSP_MEMORY_PARTITION_USER, 0, 0x100, NULL);
		// Send something to fill it up.
		char msg[256];
		sceKernelSendMsgPipe(msgpipe, msg, sizeof(msg), 0, NULL, NULL);
		MsgPipeSendWaitThread wait_s1("sending thread 1", msgpipe, NO_TIMEOUT);
		MsgPipeSendWaitThread wait_s2("sending thread 2", msgpipe, 10000);
		checkpoint("With sending threads: %08x", sceKernelDeleteMsgPipe(msgpipe));
	}

	return 0;
}
Example #2
0
void testMsgPipeSimple1() {
	Message send_message1 = {1, 2, -1};
	Message recv_message1 = {0};
	int msgpipe_capacity = 2;
	int msgpipe_trycount = 3;
	int msgpipe;
	int result;
	int n;

	msgpipe = sceKernelCreateMsgPipe("MSGPIPE", 2, 0, sizeof(Message) * msgpipe_capacity, NULL);
	//msgpipe = sceKernelCreateMsgPipe("MSGPIPE", 2, 0, 1, NULL);
	printf("CREATE:%08X\n", msgpipe);
	for (n = 0; n < msgpipe_trycount; n++)
	{
		int resultSize;
		send_message1.index = n;
		result = sceKernelTrySendMsgPipe(msgpipe, &send_message1, sizeof(Message), 0, &resultSize);
		printf("SEND[%d]:%08X, %08X, %d, %d, %d\n", n, result, resultSize, send_message1.value1, send_message1.value2, send_message1.index);
	}
	for (n = 0; n < msgpipe_trycount; n++)
	{
		memset(&recv_message1, 0, sizeof(Message));
		int resultSize;
		result = sceKernelTryReceiveMsgPipe(msgpipe, &recv_message1, sizeof(Message), 0, &resultSize);
		printf("RECV[%d]:%08X, %08X, %d, %d, %d\n", n, result, resultSize, recv_message1.value1, recv_message1.value2, recv_message1.index);
	}
	printf("DELETE:%08X\n", sceKernelDeleteMsgPipe(msgpipe));
	printf("DELETE2:%08X\n", sceKernelDeleteMsgPipe(msgpipe));
}
Example #3
0
inline void testDelete(const char *title, SceUID msgpipe) {
	int result = sceKernelDeleteMsgPipe(msgpipe);
	if (result == 0) {
		checkpoint("%s: OK", title);
	} else {
		checkpoint("%s: Failed (%08x)", title, result);
	}
}
Example #4
0
void testMsgPipeWithThreads() {
	int n;
	msgpipe = sceKernelCreateMsgPipe("MSGPIPE", 2, 0, sizeof(Message) * msgpipe_capacity, NULL);
	{
		// Create acceptor threads, that will receive messages.
		for (n = 0; n < msgpipe_threadcount; n++) {
			current_thread_id = n;
			sceKernelStartThread(sceKernelCreateThread("MSGPIPE_thread", (void *)&testMsgPipeWithThreads_thread, 0x12, 0x10000, 0, NULL), 0, NULL);
		}
		
		// Write all the messages.
		Message message = {1, 2, -1};
		int messageSize;
		int result;
		for (n = 0; n < msgpipe_writecount; n++) {
			message.index = n;
			result = sceKernelSendMsgPipe(msgpipe, &message, sizeof(Message), 0, &messageSize, NULL);
			printf("SEND[%d] : %08X, %d, %d, %d\n", n, result, message.value1, message.value2, message.index);
		}
	}
	sceKernelDeleteMsgPipe(msgpipe);
}