int main(int argc, char *argv[]) { int error_total = 0; int error_ignore = 0; srandom(getpid()); if ((argc > 1) && (strcmp(argv[1], "online") == 0)) { SOS_RUN_MODE = SOS_ROLE_CLIENT; } else { SOS_RUN_MODE = SOS_ROLE_OFFLINE_TEST_MODE; } SOS_test_section_start(0, "SOS"); TEST_sos = SOS_init(&argc, &argv, SOS_RUN_MODE, SOS_LAYER_SOS_RUNTIME); SOS_test_run(1, "SOS_init", SOS_test_show_ok(), error_ignore, error_ignore); error_total = SOS_test_all(); SOS_finalize(TEST_sos); SOS_test_run(1, "SOS_finalize", SOS_test_show_ok(), error_ignore, error_ignore); SOS_test_section_report(0, "SOS", error_total); return (error_total); }
void init() { struct ext_mem_format *ptr_exts; // structure-pointer to structure struct ext_mem_format temp_struc; // temporary structure struct inode ino_kern; struct ext_mem_format ext_mem_strucs[50]; // 386 usable RAM list format usec_t ino_sec; ubyte_t num_servs; // number of servers to read to memory uint_t tot_mem, counter, counter1; // counters byte *ptr_mem=(byte *)ext_mem_strucs; // byte-pointer to structure /* * Get absolute sector for first ivector. * It is stored in a global variable. */ sosfs_ivec_first(); /* read kernel's and server's inode sector */ ino_sec = sosfs_iget("/boot/kernel"); /* if error */ if (ino_sec == -1) { low_putstr("Inode not found\n"); while (1); } /* read kernel's inode */ sosfs_read_raw(ino_sec, &ino_kern); /* zero out the vector */ for (tot_mem=0; tot_mem<512; tot_mem++) buffer[tot_mem]=0; /* * Copy arguments from real-mode to protected-mode. * The monitor program wishes to pass the arguments to the kernel. * This is done by a little hack that uses an interrupt instruction * passing a buffer to copy from real-mode to protected-mode using * BIOS. */ kargs_init(); /* * Get total amount of RAM. * The most reliable way to know the system's memory-mapping * is by using the BIOS; we use int $0x15 function 0xe820. */ low_tot_ram(ext_mem_strucs); /* point to memory-map vector */ ptr_exts=ext_mem_strucs; /* * Traverse the structures until magic number found. * Our interrupt handler set a magic number after the last * entry returned by the BIOS handler. */ kprintf("\n"); kprintf("BIOS-provided physical-memory mappings\n"); kprintf("======================================================\n"); while (ptr_exts->acpi_ext != 0x12345) { /* if we must ignore the entry, so we do */ if (ptr_exts->reg_len == 0) continue; /* print type of memory to terminal */ switch (ptr_exts->reg_type) { case 1: kprintf("Usable RAM at "); if (ptr_exts->base_addr[0] != 0) { zero_mem(ptr_exts); put_list(ptr_exts); } break; case 2: kprintf("Reserved/unusable RAM at "); break; case 3: case 4: case 5: kprintf("ACPI RAM at "); break; } /* * Create a temporary structure and copy the entire structure * to it. * Print the address range. */ temp_struc = *ptr_exts; // copy structure temp_struc.reg_len[0] += temp_struc.base_addr[0]; kprintf("%x-", &temp_struc); kprintf("%x", temp_struc.reg_len); kprintf("\n"); for (tot_mem=0; tot_mem<512; tot_mem++) buffer[tot_mem]=0; ptr_exts++; // advance one structure } kprintf("======================================================\n"); /* * Set up initial memory mappings. * Load user-level servers to predefined physical memory and * identically map them. Map the monitor program and the kernel * also to identical physical addresses. Also map those programs' * heaps. */ load_init(); heap_init(); /* list returned by BIOS might be unsorted */ sort_free_list(); /* machine-dependent format to machine-independent format */ dep_2_indep_list(ptr_list); mmap_init(); enable_paging(); SOS_init(); }
int main(int argc, char *argv[]) { SOS_runtime *my_sos; int i; int elem; int next_elem; char pub_title[SOS_DEFAULT_STRING_LEN] = {0}; char elem_name[SOS_DEFAULT_STRING_LEN] = {0}; SOS_pub *pub; double time_now; double time_start; int MAX_SEND_COUNT; int ITERATION_SIZE; int PUB_ELEM_COUNT; int JITTER_ENABLED; double JITTER_INTERVAL; MPI_Init(&argc, &argv); /* Process command-line arguments */ if ( argc < 5 ) { fprintf(stderr, "%s\n", USAGE); exit(1); } MAX_SEND_COUNT = -1; ITERATION_SIZE = -1; PUB_ELEM_COUNT = -1; JITTER_ENABLED = 0; JITTER_INTERVAL = 0.0; for (elem = 1; elem < argc; ) { if ((next_elem = elem + 1) == argc) { fprintf(stderr, "%s\n", USAGE); exit(1); } if ( strcmp(argv[elem], "-i" ) == 0) { ITERATION_SIZE = atoi(argv[next_elem]); } else if ( strcmp(argv[elem], "-m" ) == 0) { MAX_SEND_COUNT = atoi(argv[next_elem]); } else if ( strcmp(argv[elem], "-p" ) == 0) { PUB_ELEM_COUNT = atoi(argv[next_elem]); } else if ( strcmp(argv[elem], "-j" ) == 0) { JITTER_INTERVAL = strtod(argv[next_elem], NULL); JITTER_ENABLED = 1; } else { fprintf(stderr, "Unknown flag: %s %s\n", argv[elem], argv[next_elem]); } elem = next_elem + 1; } if ( (MAX_SEND_COUNT < 1) || (ITERATION_SIZE < 1) || (PUB_ELEM_COUNT < 1) || (JITTER_INTERVAL < 0.0) ) { fprintf(stderr, "%s\n", USAGE); exit(1); } /* Example variables. */ char *str_node_id = getenv("HOSTNAME"); char *str_prog_ver = "1.0"; char var_string[100] = {0}; int var_int; double var_double; my_sos = SOS_init( &argc, &argv, SOS_ROLE_CLIENT, SOS_LAYER_APP); SOS_SET_CONTEXT(my_sos, "demo_app.main"); srandom(my_sos->my_guid); printf("demo_app starting...\n"); fflush(stdout); dlog(0, "Creating a pub...\n"); pub = SOS_pub_create(my_sos, "demo", SOS_NATURE_CREATE_OUTPUT); dlog(0, " ... pub->guid = %ld\n", pub->guid); dlog(0, "Manually configuring some pub metadata...\n"); strcpy (pub->prog_ver, str_prog_ver); pub->meta.channel = 1; pub->meta.nature = SOS_NATURE_EXEC_WORK; pub->meta.layer = SOS_LAYER_APP; pub->meta.pri_hint = SOS_PRI_DEFAULT; pub->meta.scope_hint = SOS_SCOPE_DEFAULT; pub->meta.retain_hint = SOS_RETAIN_DEFAULT; dlog(0, "Packing a couple values...\n"); var_int = 1234567890; snprintf(var_string, 100, "Hello, world!"); var_double = 0.0; int pos = -1; for (i = 0; i < PUB_ELEM_COUNT; i++) { snprintf(elem_name, SOS_DEFAULT_STRING_LEN, "example_dbl_%d", i); pos = SOS_pack(pub, elem_name, SOS_VAL_TYPE_DOUBLE, &var_double); dlog(0, " pub->data[%d]->guid == %" SOS_GUID_FMT "\n", pos, pub->data[pos]->guid); var_double += 0.0000001; } dlog(0, "Announcing\n"); SOS_announce(pub); dlog(0, "Re-packing --> Publishing %d values for %d times per iteration:\n", PUB_ELEM_COUNT, ITERATION_SIZE); SOS_TIME( time_start ); int mils = 0; int ones = 0; for (ones = 0; ones < ITERATION_SIZE; ones++) { for (i = 0; i < PUB_ELEM_COUNT; i++) { snprintf(elem_name, SOS_DEFAULT_STRING_LEN, "example_dbl_%d", i); SOS_pack(pub, elem_name, SOS_VAL_TYPE_DOUBLE, &var_double); var_double += 0.000001; } SOS_publish(pub); } /* Catch any stragglers. */ //SOS_publish(pub); dlog(0, " ... done.\n"); dlog(0, "demo_app finished successfully!\n"); SOS_finalize(my_sos); MPI_Finalize(); return (EXIT_SUCCESS); }