Exemple #1
0
int create_process(char *model) {
    int pid;
    int num_resources;
    peos_resource_t *resources;
    char *res_file;
    char *model_file = calloc(strlen(model) + strlen(".pml") + 1, sizeof(char));
    
    strcpy(model_file, model);
    strcat(model_file, ".pml");
    resources = (peos_resource_t *) peos_get_resource_list(model_file,&num_resources);    //see events.c

    if (resources == NULL) {
        fprintf(stderr, "error getting resources for model '%s'\n", model_file);
        return -1;
    }
    
    fprintf(stderr, "Executing %s:\n", model);
    
    if ((pid = peos_run(model_file,resources,num_resources)) < 0) {    //see events.c
        fprintf(stderr, "error running process\n");
        return -1;
    }
    
    if ((res_file = peos_get_resource_file(model_file)))
        peos_bind_resource_file(pid, res_file);

    fprintf(stderr, "created pid = %d\n", pid);
    return 1;
}
Exemple #2
0
void create_process(int argc, char *argv[])
{
    int pid;
    char *model, *pml_file;
    int num_resources;
    peos_resource_t *resources;

    if (argc < 2) {
	printf("usage: %s model\n", argv[0]);
	return;
    }

    model = argv[1];
    pml_file = add_ext(model, ".pml");

    printf("Getting resources for %s\n", pml_file);
    resources = (peos_resource_t *) peos_get_resource_list(pml_file, &num_resources);

    if (resources == NULL) {
        printf("error getting resources\n");
	free(pml_file);
	return;
    }
    
    printf("Executing %s:\n", pml_file);
    
    if ((pid = peos_run(pml_file, resources, num_resources)) < 0) {
	peos_perror("couldn't create process");
    } 
    else {
	printf("Created pid = %d\n", pid);
    }
    free(pml_file);
}
Exemple #3
0
void list_resources(int argc, char *argv[])
{
    int i;
    char *model, *model_file, *pml_file;
    int num_resources;
    peos_resource_t *resources;

    if (argc < 2) {
	printf("usage: %s model\n", argv[0]);
	return;
    }

    model = argv[1];
    pml_file = add_ext(model, ".pml");
    model_file = (char *)find_file(pml_file);
    free(pml_file);
    if (model_file == NULL) {
        printf("error: model file %s not found\n", model);
        return;
    }
    resources = (peos_resource_t *) peos_get_resource_list(model_file,&num_resources);


    if (resources == NULL) {
        printf("error getting resources\n");
        return;
    }
    for(i = 0; i < num_resources; i++) {
        printf("%s=%s\n", resources[i].name, resources[i].value) ;
    }

    free(resources);
}
Exemple #4
0
int main()
{

    /* create a test process table */	
    int pid;
    int i;
    char *model = "test_process.pml";
    peos_resource_t *resources;
    int num_resources;
    char *process_filename = "test.dat"; 

    peos_set_process_table_file(process_filename);

    resources = (peos_resource_t *) peos_get_resource_list(model,&num_resources);
    pid = peos_run(model, resources, num_resources);
	
    exit(0);

}	
int create_process(char *model)
{
    int pid;
    int num_resources;
    peos_resource_t *resources;

    resources = (peos_resource_t *) peos_get_resource_list(model,&num_resources);

    if (resources == NULL) {
        printf("error getting resources\n");
	return -1;
    }
    
    printf("Executing %s:\n", model);
    
    if ((pid = peos_run(model,resources,num_resources)) < 0) {
	printf("couldn't create process\n");
	return -1;
    } 
    else {
	printf("Created pid = %d\n", pid);
	return 1;
    }
}