Exemplo n.º 1
0
int main()
{
	int ret, err, i;

	setbuf(stdout, NULL);
	setbuf(stderr, NULL);
	
	printf("Setting KUXSE file labels\n");


	memset(&glob_buff, 0 , sizeof(glob_t));
	ret = glob("/*", 0, NULL, &glob_buff);
	if (ret != 0) {
		perror("glob :");
		exit(-1);
	}

	i = 0;
	process_thread(&i);

	globfree(&glob_buff);
	return 0;
}
Exemplo n.º 2
0
void *process_thread(int *cnt)
{
	int k, j = *cnt;

	setbuf(stdout, NULL);
	setbuf(stderr, NULL);
	
	printf("j=%d\n", j);

#ifdef MULP
	for (k = j; k < glob_buff.gl_pathc; k += 4) {
#else
	for (k = j; k < glob_buff.gl_pathc; k++) {
#endif
		//printf("%s %d \n", glob_buff.gl_pathv[k], k);
		if (strstr(glob_buff.gl_pathv[k], "proc") != NULL)
			continue;
		process_one(glob_buff.gl_pathv[k]);
	}
	fflush(stdout);
	return;

}

int main()
{
	int ret, err, i;
#ifdef MULP
	pthread_t pt[4];
	pthread_attr_t pattr[4];
	void *res = NULL;
	int tmp[4];
#endif

	setbuf(stdout, NULL);
	setbuf(stderr, NULL);
	
	printf("Setting KUXSE file labels\n");

#if 0
	pt = (pthread_t *)malloc(4 * sizeof(pthread_t));
	if (pt == NULL) {
		perror("malloc ");
		exit(-1);
	}
#endif

	memset(&glob_buff, 0 , sizeof(glob_t));
	//ret = glob("/tmp/tttt/*", GLOB_TILDE | GLOB_NOCHECK, NULL, &glob_buff);
	ret = glob("/*", 0, NULL, &glob_buff);
	if (ret != 0) {
		perror("glob :");
		exit(-1);
	}

#ifdef MULP
	for (i = 0; i < 4; i++) {
		cpu_set_t cpuset;
		CPU_ZERO(&cpuset);
		CPU_SET(i, &cpuset);
		tmp[i] = i;

		pthread_attr_init(&pattr[i]);
	
		ret = pthread_attr_setaffinity_np(&pattr[i],
				sizeof(cpu_set_t), &cpuset);
		if (ret != 0) {
			perror("pthread_attr_set ");
			exit(-1);
		}

		ret = pthread_create(&pt[i], &pattr[i], &process_thread,
				&tmp[i]);
		if (ret != 0) {
			perror("pthread_create ");
			exit(-1);
		}

		pthread_attr_destroy(&pattr[i]);
		//sleep(2);
	}

	for (i = 0; i < 4; i++) {
		ret = pthread_join(pt[i], NULL);
		if (ret != 0) {
			perror("pthread_join ");
			exit(-1);
		}
		//if (res)
		//	free(res);
	}
#else
	i = 0;
	process_thread(&i);
#endif

	globfree(&glob_buff);
	return 0;
}
Exemplo n.º 3
0
	/**
	 * Creates a thread to execute code in the process.
	 *
	 * @param address The address to start executing at.
	 * @param parameter The parameter to pass to the thread.
	 * @return The thread handle.
	 */
	uint32_t CreateThread(uint32_t address, uint32_t parameter) { StackTrace trace(__METHOD__, __FILE__, __LINE__);
		return process_thread(_handle, address, parameter);
	}