Example #1
0
static jint tagThreads(ThreadModule * threadModule, jvmtiEnv * jvmti, jlong beginTag) {
	jthread * threads;
	jvmtiError err;
	int i;

	err = (*jvmti)->GetAllThreads(jvmti, &threadModule->threadCount, &threads);
	CHECK_ERROR_AND_RETURN(jvmti, err, "get all thread error", JNI_ERR);

	threadModule->threadInfos = calloc(threadModule->threadCount, sizeof(ThreadInfo));
	for (i = 0; i < threadModule->threadCount; i++) {
		jvmtiThreadInfo aInfo;

		int tag = beginTag + i;

		err = (*jvmti)->GetThreadInfo(jvmti, threads[i], &aInfo);
		print_if_error(jvmti, err, "get thread info error");
		if (err == JVMTI_ERROR_NONE) {
			(*jvmti)->SetTag(jvmti, threads[i], tag);
			threadModule->threadInfos[i].name = strdup(aInfo.name);
#ifdef DEBUG
			ulog("tag thread: %s to %d\n", threadModule->threadInfos[i].name, tag);
#endif
			deallocate(jvmti, aInfo.name);
		}
	}

	deallocate(jvmti, threads);
	return JNI_OK;
}
Example #2
0
int main(){
    pid_t child1_pid, child2_pid, child3_pid, child4_pid;
    int status = 0;
    child1_pid = print_if_error(fork());
    if (child1_pid == 0) {
        print_id();
        printf("Computing binomial coefficient");
    }
    child2_pid = print_if_error(fork());
    if (child2_pid == 0){
        sleep(1);
        print_id();
        process(2, 2);
    }
    else {
        waitpid(child1_pid, &status, 0);
        printf("child1 terminated\n");
        
        child3_pid = print_if_error(fork());
        
        if(child3_pid == 0){
            sleep(2);
            print_id();
            process(3, 3);
        }
        else{
            waitpid(child3_pid, &status, 0);
            printf("child 3 terminated\n");
        }
        
        waitpid(child2_pid, &status, 0);
        printf("child2 terminated\n");
        
        child4_pid = print_if_error(fork());
        if(child4_pid == 0){
            sleep(1);
            print_id();
            system("ls -l");
        } else {
            waitpid(child4_pid, &status, 0);
            printf("child4 terminated\n");
        }
    }
    
    return 0;
}
Example #3
0
void analyse_if(Cond *ifcond, sym_table *table, char *scope_id, int line_no) {
    //Analyse condition
    Type c = get_expr_type(ifcond->cond, NULL, table, scope_id, line_no);
    if (c != BOOL_TYPE) {
        print_if_error(ifcond->cond, c, line_no);
        isValid = FALSE;
    }
    //Analyse then branch
    analyse_statements(ifcond->then_branch, table, scope_id);
    //Analyse else branch
    analyse_statements(ifcond->else_branch, table, scope_id);

}