Ejemplo n.º 1
0
int main(int argc, char *argv[])
{
	Attr attr;
	size_t stacksize = 10 * 1024 * 1024;
	attr.setstacksize(stacksize);
	perror("setstacksize");
	
	MyThread a(&attr);
	a.start();

	size_t getsize = 0;
	attr.getstacksize(&getsize);
	printf("stacksize: %lu\n", getsize);

	size_t guardsize = 0;
	attr.getguardsize(&guardsize);
	printf("guardsize: %lu\n", guardsize);
	// DWORD id = GetCurrentProcessId();
	
	// pid_t pid = getpid();
	// pthread_t tid = pthread_self();
	// printf("pid %lu tid %lu (0x%lX)\n",
	// 	   static_cast<unsigned long>(pid),
	// 	   static_cast<unsigned long>(tid),
	// 	   static_cast<unsigned long>(tid));

	// // struct msg *workq = new struct msg;
	// // Test test;
	// // test.test();
//	test();
	DoSomething ds;
	Thread thread(&ds);
	thread.start();

	// Attr attr;
	// printf("detachstate:%d\n", attr.getdetachstate());
	// void *stackaddr = NULL;
	// size_t stacksize = 0;
	// attr.getstacksize(&stacksize);
	// printf("stack size: %luM\n", stacksize / 1024 / 1024);

	printf("main exit\n");
	// Thread::exit();
	// pthread_exit(NULL);
	getchar();
	return 0;
}
Ejemplo n.º 2
0
    virtual void run() {
		pid_t pid = getpid();
        pthread_t tid = self();
		printf("subthread pid %lu tid %lu (0x%lX)\n",
			   static_cast<unsigned long>(pid),
			   static_cast<unsigned long>(tid),
			   static_cast<unsigned long>(tid));
		// std::cout << tid << std::endl;

		Attr attr;
		printf("detachstate:%d\n", attr.getdetachstate());
		// void *stackaddr = NULL;
		size_t stacksize = 0;
		attr.getstacksize(&stacksize);
		printf("stack size: %lu\n", stacksize);
		
    }