Example #1
0
main()
{
register int i,j;   /* use em for FOR loops */
point3d pointi;     /* declare one instance of our point3d struct */
int color =1;       /* color to draw triangle */
char com;           /* for user input */




puts("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
puts("1-Spin Y  2-Spin X  3-Spin Z  9-Quit\n");


theport = a_init();                   /* line a invokage */    
	theport -> plane0 = 1;
	theport -> plane1 = 0;
	theport -> plane2 = 0;
	theport -> plane3 = 0;


   
for(i=0;i<nlines;i++)  /* set up points-to-connect lookup table*/
{ drawpt1[i] = point_[linefrom[i]];
  drawpt2[i] = point_[lineto[i]];  
}

com = 0x32;                       /* set to spin about x */

while( com != 0x39)
{
if( Bconstat(2) )       /* if keypress */
 com = Bconin(2);       /* get input */


                                  /* The main loop */
 for(i=0;i<npts;i++)
   {
   pointi = point_[i];        /* get current point data. We do this for efficiency, since we will use this value many times within one loop
                                 it's more efficient to compute it's value only once */
   
    if(com == 0x31) {              /* spin y */
               point_[i].x =( mu_global_c(pointi.x)  -
                              mu_global_s(pointi.z))>>BITSH; /* since our points are scaled AND or trig angles, sin&cos values are scaled we must divide by scale once here*/
               point_[i].z =( mu_global_s(pointi.x) +
                              mu_global_c(pointi.z))>>BITSH;

                    }
    if(com == 0x32) {              /* spin x */
                point_[i].y =( mu_global_c(pointi.y)  +
                               mu_global_s(pointi.z))>>BITSH;
                point_[i].z =( -(mu_global_s(pointi.y)) +
                                 mu_global_c(pointi.z))>>BITSH;
                    }
    if(com == 0x33) {              /* spin z */
                point_[i].x =( mu_global_c(pointi.x)  +
                               mu_global_s(pointi.y))>>BITSH;
                point_[i].y =( mu_global_c(pointi.y)  -
                               mu_global_s(pointi.x))>>BITSH;
                    }
Example #2
0
static void async_test(const char *fname, int block_size, int nblocks, int rsize)
{
	int fd;
	struct aio_ring *ring;
	off_t offset=0;
	char buf[rsize];
	int i=0;

	offset=0;
	start_timer();
	fd = open(fname, O_RDONLY);
	if (fd == -1) {
		perror(fname);
		exit(1);
	}

	ring = a_init(fd, block_size, nblocks);
	if (ring == NULL) {
		fprintf(stderr, "a_init faild\n");
		exit(1);
	}

	while (a_read(ring, buf, sizeof(buf), offset) > 0) {
		offset += sizeof(buf);
		if (++i % 5 == 0) {
			offset -= 2*sizeof(buf);
		}
	}

	printf("async: %.3f MByte/sec\n", 1.0e-6 * offset / end_timer());
	a_close(ring);
}
Example #3
0
File: main.c Project: jaybi42/21sh
int				main(int ac, char **argv)
{
	init_global(ac, argv);
	if (init_env(&g_env, &g_lenv) == 1 || (a_init() == -1))
		return (1);
	g_hash = hash_table(get_path(g_env, g_lenv));
	xmalloc(100);
	if (sh21() == 1)
	{
		hash_del(&(g_hash));
		return (1);
	}
	hash_del(&(g_hash));
	return (0);
}
Example #4
0
int
bullet_init()
{
    vir_bytes	size;
    peer_bits	test_var ;

    /* Initialize to logging */
    bs_log_msgs=1 ;
#ifndef USER_LEVEL    
    bs_print_msgs = 0;
#endif
    bs_debug_level = DEBUG_LEVEL ;

    /* Check that inode size is sensible - otherwise the compiler is odd */
    if (sizeof (Inode) != INODE_SIZE)
    {
	bwarn("Inode size is %d, should be %d\nServer is inactive!",
						sizeof(Inode), INODE_SIZE);
	return 0;
    }

    /* Check that the peer bitmap can contain all members */
    test_var=1 ;
    test_var <<= (S_MAXMEMBER-1) ;
    if ( test_var == 0 || test_var!= (1<<(S_MAXMEMBER-1)) ) {
	bwarn("type \"peer_bits\" is too small\nServer is inactive!");
	return 0;
    }

    
    /* Figure out which vdisk to use and read the superblock */
    if (get_disk_server_cap() == 0)
	return 0;

    /* Now that we know there is a disk we can announce ourselves */
    message("BULLET SERVER INITIALIZATION");

    /*
     * Set up pointers to beginning and end of buffer cache.
     * Make sure that our buffer cache is block aligned!  The inode table
     * goes at the start of the cache memory and relies on blocksize
     * alignment.
     * NB: We must leave some memory free for other kernel threads and
     *     possible user processes (such as soap).  It leaves
     *     BS_MEM_RESERVE bytes if no fixed cache size is defined.
     */
#ifdef BULLET_MEMSIZE
    size = BULLET_MEMSIZE;
#else
    size = seg_maxfree();
    if (size < BS_MEM_RESERVE)
    {
	bpanic(
	  "bullet_init: memory reserve (0x%x) exceeds free memory (0x%x)\n",
	    BS_MEM_RESERVE, size);
    }
    size -= BS_MEM_RESERVE;
#endif /* BULLET_MEMSIZE */

    /*
     * The following allocate may take a long time, especially when lots
     * of memory (32Mb :-) is involved. However, since kernel threads are
     * not preempted the enqueued interrupt routines never get a chance to
     * run, and eventually the interrupt queue will overflow causing a
     * panic.
     */
#ifndef USER_LEVEL
    disable();
#endif /* USER_LEVEL */
    Bc_begin = (bufptr) aalloc(size, (int) Blksizemin1 + 1);
#ifndef USER_LEVEL
    enable();
#endif /* USER_LEVEL */

    Bc_end = Bc_begin + size;
    if (Bc_begin >= Bc_end)
	bpanic("bullet_init: no buffer cache");

    /* Initialise resource allocation.  NB: cache_mem is initially free! */
    a_init(BYTES_TO_MEG(Bc_end - Bc_begin) +
	   BLOCKS_TO_MEG(Superblock.s_numblocks, Blksizemin1 + 1));
    if (a_begin(A_CACHE_MEM, (Res_addr) Bc_begin, (Res_addr) Bc_end) < 0)
	bpanic("Cannot begin resource allocator for buffer cache.\n");

    /* Initialise buffer cache management */
    cache_init();

    Largest_file_size = (b_fsize) a_notused(A_CACHE_MEM);

    /* Print some cheery statistics about the current state of the server */
    message("Buffer cache size = 0x%lx bytes", Bc_end - Bc_begin);
    message("Largest possible file size = 0x%lx bytes",Largest_file_size);

    /* Calculate the size of the super struct in local blocks */
    /* It is the of disk blocks into a D_PHYSBLK */
    if ( D_PHYS_SHIFT<=Superblock.s_blksize ) {
	/* Super info takes one block or less */
	bs_super_size= 1 ;
   } else {
	/* To be honest, bs_supersize will always be one, because
	 * D_PHYS_SHIFT seems to be the minimum.
         */
	bwarn("Super block takes more then one block") ;
	bs_super_size= 1 << (D_PHYS_SHIFT-Superblock.s_blksize) ;
    }

    /* Super Block Lock */
    mu_init(&SuperLock) ;

    /* Init group structures */
    bs_grp_init() ;

    return 1 ;
}