当前位置: 首页>>代码示例>>C++>>正文


C++ send_recv函数代码示例

本文整理汇总了C++中send_recv函数的典型用法代码示例。如果您正苦于以下问题:C++ send_recv函数的具体用法?C++ send_recv怎么用?C++ send_recv使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了send_recv函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: task_hd

/**
 * Main loop of HD driver.
 *
 *****************************************************************************/
PUBLIC void task_hd()
{
    MESSAGE msg;
    init_hd();
    while (1) {
        send_recv(RECEIVE, ANY, &msg);
        int src = msg.source;

        switch (msg.type) {
        case DEV_OPEN:
            hd_open(msg.DEVICE);
            break;

        case DEV_CLOSE:
            hd_close(msg.DEVICE);
            break;

        case DEV_READ:
        case DEV_WRITE:
            hd_rdwt(&msg);
            break;

        case DEV_IOCTL:
            hd_ioctl(&msg);
            break;

        default:
            dump_msg("HD driver::unknown msg", &msg);
            spin("FS::main_loop (invalid msg.type)");
            break;
        }

        send_recv(SEND, src, &msg);
    }
}
开发者ID:wwssllabcd,项目名称:myOS,代码行数:39,代码来源:hd.c

示例2: task_hd

PUBLIC void task_hd()
{
    MESSAGE msg;
    init_hd();

    while (true) {
        send_recv(RECEIVE, ANY, &msg);
        int src = msg.source;

        switch (msg.type) {
        case DEV_OPEN:
            hd_identify(0);
            //hd_open(msg.DEVICE);
            break;
        case DEV_CLOSE:
            hd_close(msg.DEVICE);
            break;
        case DEV_READ:
        case DEV_WRITE:
            hd_rdwt(&msg);
            break;
        case DEV_IOCTL:
            hd_ioctl(&msg);
            break;
        default:
            kprintf("[KERNEL ERROR]HD driveer::unknown msg");
            break;
        }

        send_recv(SEND, src, &msg);
    }
}
开发者ID:yankaifyyy,项目名称:Owindy-S,代码行数:32,代码来源:hd.c

示例3: task_hd

PUBLIC void task_hd() {
    MESSAGE msg;

    init_hd();
    printl("Task HD begins.\n");
    while (TRUE) {
	send_recv(RECEIVE, ANY, &msg);

	int src = msg.source;

	switch(msg.type) {
	case DEV_OPEN:
	    /* 获得硬盘的信息 */
	    /* hd_identify(0); */
	    hd_open(msg.DEVICE);
	    break;
	case DEV_CLOSE:
	    hd_close(msg.DEVICE);
	    break;
	case DEV_READ:
	case DEV_WRITE:
	    hd_rdwt(&msg);
	    break;
	case DEV_IOCTL:
	    hd_ioctl(&msg);
	    break;
	default:
	    panic("HD driver::unknown msg");
	}

	send_recv(SEND, src, &msg);
    }
}
开发者ID:Zach41,项目名称:OS,代码行数:33,代码来源:hd.c

示例4: task_tty

/**
 * <Ring 1> Main loop of task TTY.
 *****************************************************************************/
PUBLIC void task_tty()
{
	TTY *	tty;
	MESSAGE msg;

	init_keyboard();

	for (tty = TTY_FIRST; tty < TTY_END; tty++)
		init_tty(tty);

	select_console(0);

	while (1) {
		for (tty = TTY_FIRST; tty < TTY_END; tty++) {
			do {
				tty_dev_read(tty);
				tty_dev_write(tty);
			} while (tty->ibuf_cnt);
		}

		send_recv(RECEIVE, ANY, &msg);

		int src = msg.source;
		assert(src != TASK_TTY);

		TTY* ptty = &tty_table[msg.DEVICE];

		switch (msg.type) {
		case DEV_OPEN:
			reset_msg(&msg);
			msg.type = SYSCALL_RET;
			send_recv(SEND, src, &msg);
			break;
		case DEV_READ:
			tty_do_read(ptty, &msg);
			break;
		case DEV_WRITE:
			tty_do_write(ptty, &msg);
			break;
		case HARD_INT:
			/**
			 * waked up by clock_handler -- a key was just pressed
			 * @see clock_handler() inform_int()
			 */
			key_pressed = 0;
			continue;
		default:
			dump_msg("TTY::unknown msg", &msg);
			break;
		}
	}
}
开发者ID:wsxiaoys,项目名称:OS-Practice,代码行数:55,代码来源:tty.c

示例5: task_fs

void task_fs()
{
	printk("Task FS begins.\n");

	init_buffer( 0x300000 );
	init_fs();

	MESSAGE msg;

	while(1)
	{
		send_recv( RECEIVE, ANY, &msg );
		int src = msg.source;
		switch(msg.type)
		{
			case OPEN:
				msg.FD = do_open( &msg );
				break;
			case CLOSE:
				msg.RETVAL = do_close( &msg );
				break;
			case READ:
			case WRITE:
				msg.CNT = do_rdwr( &msg );
				break;
			case RESUME_PROC:
				src = msg.PROC_NR;
				break;
			case FORK:
				msg.RETVAL = fs_fork( &msg );
				break;
			case EXIT:
				msg.RETVAL = fs_exit( &msg );
				break;
			default:
				dump_msg("FS:unknow message:", &msg );
				assert(0);
				break;
		}

		if( msg.type != SUSPEND_PROC )
		{
			msg.type = SYSCALL_RET;
			send_recv( SEND, src, &msg );
		}
	}
	spin("FS");
}
开发者ID:qpig,项目名称:sfs,代码行数:48,代码来源:fs.c

示例6: execv

PUBLIC int execv(const char *path, char *argv[])
{
	char **p = argv;
	char arg_stack[PROC_ORIGIN_STACK];
	int stack_len = 0;

	while(*p++) {
		stack_len += sizeof(char*);
	}

	*((int*)(&arg_stack[stack_len])) = 0;
	stack_len += sizeof(char*);

	char ** q = (char**)arg_stack;
	for (p = argv; *p != 0; p++) {
		*q++ = &arg_stack[stack_len];

		strcpy(&arg_stack[stack_len], *p);
		stack_len += strlen(*p);
		arg_stack[stack_len] = 0;
		stack_len++;
	}

	MESSAGE msg;
	msg.type = EXEC;
	msg.PATHNAME = (void*)path;
	msg.NAME_LEN = strlen(path);
	msg.BUF	= (void*)arg_stack;
	msg.BUF_LEN	= stack_len;

	send_recv(BOTH, TASK_MM, &msg);

	return msg.RETVAL;
}
开发者ID:yankaifyyy,项目名称:Owindy-S,代码行数:34,代码来源:exec.c

示例7: main

int main()
{
        fd_set master;
        fd_set read_fds;
        int fdmax, i;
        int sockfd= 0;
        struct sockaddr_in my_addr, client_addr;
        
        FD_ZERO(&master);
        FD_ZERO(&read_fds);
        connect_request(&sockfd, &my_addr);
        printf("debug: %i", sockfd);
        FD_SET(sockfd, &master);
        
        fdmax = sockfd;
        while(1){
                read_fds = master;
                if(select(fdmax+1, &read_fds, NULL, NULL, NULL) == -1){
                        perror("select");
                        exit(4);
                }
                for (i = 0; i <= fdmax; i++){
                        if (FD_ISSET(i, &read_fds)){
                                if (i == sockfd){
                                        connection_accept(&master, &fdmax, sockfd, &client_addr);
                                }else{
                                        send_recv(i, &master, sockfd, fdmax);
                                }
                        }
                }
        }
        return 0;
}
开发者ID:vfa-taipa,项目名称:sandbox,代码行数:33,代码来源:kt_server.c

示例8: read_super_block

/**
 * <Ring 1> Read super block from the given device then write it into a free
 *          super_block[] slot.
 * 
 * @param dev  From which device the super block comes.
 *****************************************************************************/
PRIVATE void read_super_block(int dev)
{
	int i;
	MESSAGE driver_msg;

	driver_msg.type		= DEV_READ;
	driver_msg.DEVICE	= MINOR(dev);
	driver_msg.POSITION	= SECTOR_SIZE * 1;
	driver_msg.BUF		= fsbuf;
	driver_msg.CNT		= SECTOR_SIZE;
	driver_msg.PROC_NR	= TASK_FS;
	assert(dd_map[MAJOR(dev)].driver_nr != INVALID_DRIVER);
	send_recv(BOTH, dd_map[MAJOR(dev)].driver_nr, &driver_msg);

	/* find a free slot in super_block[] */
	for (i = 0; i < NR_SUPER_BLOCK; i++)
		if (super_block[i].sb_dev == NO_DEV)
			break;
	if (i == NR_SUPER_BLOCK)
		panic("super_block slots used up");

	assert(i == 0); /* currently we use only the 1st slot */

	struct super_block * psb = (struct super_block *)fsbuf;

	super_block[i] = *psb;
	super_block[i].sb_dev = dev;
}
开发者ID:yishuiliunian,项目名称:QtechComputer,代码行数:34,代码来源:main.c

示例9: cons_write

/**
 * Write chars to console.
 * 
 * @param tty The TTY struct.
 *****************************************************************************/
PRIVATE void cons_write(TTY * tty)
{
	char buf[TTY_OUT_BUF_LEN];
	char * p = tty->tty_outbuf;
	int i = tty->tty_outleft;
	int j;

	/* Nothing to write */
	if (i == 0) return;
	while (i) {
		int bytes = min(TTY_OUT_BUF_LEN, i);
		data_copy(TASK_TTY, D, buf, tty->tty_outprocnr, D, p, bytes);
		for (j = 0; j < bytes; j++)
		{
			tty->tty_outcnt++;
			out_char(tty, buf[j]);
		}
		tty->tty_outleft -= bytes;
		i -= bytes;
		p += bytes;
	}

	flush((CONSOLE *)tty->tty_dev);

	if (tty->tty_outleft == 0) {	/* done, reply to caller */
		MESSAGE msg;
		msg.type = tty->tty_outreply;
		msg.PROC_NR = tty->tty_outprocnr;
		msg.CNT = tty->tty_outcnt;
		send_recv(SEND, tty->tty_outcaller, &msg); 
	}
}
开发者ID:Jimx-,项目名称:lyos,代码行数:37,代码来源:console.c

示例10: main

int main()
{
        int sockfd, fdmax, i;
        struct sockaddr_in server_addr;
        fd_set master;
        fd_set read_fds;
        char name[20];
        printf("Enter your name: ");
        gets(name);

        connect_request(&sockfd, &server_addr);
        send(sockfd, name, strlen(name), 0);

        FD_ZERO(&master);
        FD_ZERO(&read_fds);
        FD_SET(0, &master);
        FD_SET(sockfd, &master);
        fdmax = sockfd;
        
        while(1){
                read_fds = master;
                if(select(fdmax+1, &read_fds, NULL, NULL, NULL) == -1){
                        perror("select");
                        exit(4);
                }
                
                for(i=0; i <= fdmax; i++ )
                        if(FD_ISSET(i, &read_fds))
                                send_recv(i, sockfd);
        }
        printf("client-quited\n");
        close(sockfd);
        return 0;
}
开发者ID:rahulgandhi,项目名称:Chat-Application,代码行数:34,代码来源:client.c

示例11: request_readwrite

/**
 * <Ring 1> Send read/write request.
 * @param  fs_ep      Endpoint of FS driver.
 * @param  dev        On which device this file resides.
 * @param  num        Inode nr.
 * @param  pos        Where to read/write.
 * @param  rw_flag    Read or write.
 * @param  src        Who wanna read/write.
 * @param  buf        Buffer.
 * @param  nbytes     How many bytes to read/write.
 * @param  newpos     [OUT] New position.
 * @param  bytes_rdwt [OUT] How many bytes read/written. 
 * @return            Zero on success. Otherwise an error code.
 */
PUBLIC int request_readwrite(endpoint_t fs_ep, dev_t dev, ino_t num, u64 pos, int rw_flag, endpoint_t src,
    void * buf, int nbytes, u64 * newpos, int * bytes_rdwt)
{
    MESSAGE m;
    m.type = FS_RDWT;
    m.RWDEV = dev;
    m.RWINO = num;
    m.RWPOS = pos;
    m.RWFLAG = rw_flag;
    m.RWSRC = src;
    m.RWBUF = buf;
    m.RWCNT = nbytes;

    send_recv(BOTH, fs_ep, &m);

    if (m.type != FSREQ_RET) {
        printl("VFS: request_readwrite: received invalid message.");
        return EINVAL;
    }

    *newpos = m.RWPOS;
    *bytes_rdwt = m.RWCNT;

    return m.RWRET;
}
开发者ID:Jimx-,项目名称:lyos,代码行数:39,代码来源:read_write.c

示例12: do_ioctl

PUBLIC int do_ioctl(MESSAGE * p)
{
    int fd = p->FD;
    struct file_desc * filp = pcaller->filp[fd];

    struct inode * pin = filp->fd_inode;

    int file_type = pin->i_mode & I_TYPE;
    if (file_type != I_CHAR_SPECIAL && file_type != I_BLOCK_SPECIAL) return ENOTTY;

    dev_t dev = pin->i_specdev;

    if (file_type == I_BLOCK_SPECIAL) {

    } else {
        MESSAGE msg_to_driver;

        msg_to_driver.type = DEV_IOCTL;
        msg_to_driver.DEVICE = MINOR(dev);
        msg_to_driver.REQUEST = p->REQUEST;
        msg_to_driver.BUF = p->BUF;
        msg_to_driver.PROC_NR = p->source;

        assert(dd_map[MAJOR(dev)].driver_nr != INVALID_DRIVER);
        send_recv(BOTH, dd_map[MAJOR(dev)].driver_nr, &msg_to_driver);
    }

    return 0;
}
开发者ID:Jimx-,项目名称:lyos,代码行数:29,代码来源:device.c

示例13: init_fs

/**
 * <Ring 1> Do some preparation.
 * 
 *****************************************************************************/
PRIVATE void init_fs()
{
	int i;

	/* f_desc_table[] */
	for (i = 0; i < NR_FILE_DESC; i++)
		memset(&f_desc_table[i], 0, sizeof(struct file_desc));

	/* inode_table[] */
	for (i = 0; i < NR_INODE; i++)
		memset(&inode_table[i], 0, sizeof(struct inode));

	/* super_block[] */
	struct super_block * sb = super_block;
	for (; sb < &super_block[NR_SUPER_BLOCK]; sb++)
		sb->sb_dev = NO_DEV;

	/* open the device: hard disk */
	MESSAGE driver_msg;
	driver_msg.type = DEV_OPEN;
	driver_msg.DEVICE = MINOR(ROOT_DEV);
	assert(dd_map[MAJOR(ROOT_DEV)].driver_nr != INVALID_DRIVER);
	send_recv(BOTH, dd_map[MAJOR(ROOT_DEV)].driver_nr, &driver_msg);

	/* make FS */
	mkfs();

	/* load super block of ROOT */
	read_super_block(ROOT_DEV);

	sb = get_super_block(ROOT_DEV);
	assert(sb->magic == MAGIC_V1);

	root_inode = get_inode(ROOT_DEV, ROOT_INODE);
}
开发者ID:yishuiliunian,项目名称:QtechComputer,代码行数:39,代码来源:main.c

示例14: _stlink_usb_read_all_regs

void _stlink_usb_read_all_regs(stlink_t *sl, reg *regp) {
    struct stlink_libusb * const slu = sl->backend_data;
    unsigned char* const cmd = sl->c_buf;
    unsigned char* const data = sl->q_buf;
    ssize_t size;
    uint32_t rep_len = 84;
    int i = fill_command(sl, SG_DXFER_FROM_DEV, rep_len);

    cmd[i++] = STLINK_DEBUG_COMMAND;
    cmd[i++] = STLINK_DEBUG_READALLREGS;
    size = send_recv(slu, 1, cmd, slu->cmd_len, data, rep_len);
    if (size == -1) {
        printf("[!] send_recv\n");
        return;
    }
    sl->q_len = (size_t) size;
    stlink_print_data(sl);
    for(i=0; i<16; i++)
        regp->r[i]= read_uint32(sl->q_buf, i*4);
    regp->xpsr       = read_uint32(sl->q_buf, 64);
    regp->main_sp    = read_uint32(sl->q_buf, 68);
    regp->process_sp = read_uint32(sl->q_buf, 72);
    regp->rw         = read_uint32(sl->q_buf, 76);
    regp->rw2        = read_uint32(sl->q_buf, 80);
    if (sl->verbose < 2)
        return;

    DLOG("xpsr       = 0x%08x\n", read_uint32(sl->q_buf, 64));
    DLOG("main_sp    = 0x%08x\n", read_uint32(sl->q_buf, 68));
    DLOG("process_sp = 0x%08x\n", read_uint32(sl->q_buf, 72));
    DLOG("rw         = 0x%08x\n", read_uint32(sl->q_buf, 76));
    DLOG("rw2        = 0x%08x\n", read_uint32(sl->q_buf, 80));
}
开发者ID:PetteriAimonen,项目名称:stlink,代码行数:33,代码来源:stlink-usb.c

示例15: node1

int node1(const char *url)
{
        int sock = nn_socket(AF_SP, NN_PAIR);
        assert(sock >= 0);
        assert(nn_connect(sock, url) >= 0);
        send_recv(sock, NODE1);
        return nn_shutdown (sock, 0);
}
开发者ID:shitfSign,项目名称:nanomsg-tutorial,代码行数:8,代码来源:pair.c


注:本文中的send_recv函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。