Example #1
0
void init_disk_driver(DiskDevice dd, void *mem_start, unsigned long mem_length, FreeSectorDescriptorStore *fsds_ptr) {
    *fsds_ptr = create_fsds();
    create_free_sector_descriptors(*fsds_ptr, mem_start, mem_length);
    freeSectorDescriptorStore = *fsds_ptr;
    diskDevice = dd;
    readVoucherBuffer = createBB(BUFFER_SIZE);

    writeVoucherBuffer = createBB(BUFFER_SIZE);

    pthread_create(&readThread, NULL, readThreadRun, NULL);
    pthread_create(&writeThread, NULL, writeThreadRun, NULL);
}
Example #2
0
void init_network_driver(NetworkDevice nd, void *mem_start, unsigned long mem_length, FreePacketDescriptorStore *fpds_ptr){
	pthread_t sendthread;
	pthread_t getthread;
	pthread_t bufferthread;	
	*fpds_ptr = create_fpds();
	fpds = *fpds_ptr;
	int i;
	incoming = malloc(sizeof(BoundedBuffer)*(MAX_PID+1)); // mallocing the space for array of bounded buffers that represent the "cubbyholes" in which packets from the network device will be stored for each process
	for (i = 0; i<=MAX_PID;i++){
		incoming[i] = createBB(3);	
	}
	netdev = nd;
	outgoing = createBB(6); // a bounded buffer that facilitates applications queing up the packets they wish to be sent out.
	buffer = createBB(6); // buffer that gives some wiggle room for recovery if a large flurry of packets arrive.
	create_free_packet_descriptors(fpds, mem_start, mem_length);
	pthread_create(&sendthread, NULL,sending_thread, NULL);
	pthread_create(&getthread, NULL,getting_thread, NULL);
	pthread_create(&bufferthread, NULL,buffer_thread, NULL);
}