⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 server7.c

📁 经典的linux源码
💻 C
字号:
/* include servproc */#include	"unpipc.h"#include	<math.h>#include	"squareproc.h"#include	"sqrtproc.h"voidsquareproc(void *cookie, char *dataptr, size_t datasize,		   door_desc_t *descptr, size_t ndesc){	squareproc_in_t	in;	squareproc_out_t	out;		memcpy(&in, dataptr, min(sizeof(in), datasize));	printf("squareproc: thread id %ld, arg = %ld\n",		   pr_thread_id(NULL), in.arg1);	sleep(5);	out.res1 = in.arg1 * in.arg1;	Door_return((char *) &out, sizeof(out), NULL, 0);}voidsqrtproc(void *cookie, char *dataptr, size_t datasize,		 door_desc_t *descptr, size_t ndesc){	sqrtproc_in_t	in;	sqrtproc_out_t	out;		memcpy(&in, dataptr, min(sizeof(in), datasize));	printf("sqrtproc: thread id %ld, arg = %ld\n",		   pr_thread_id(NULL), in.arg1);	sleep(5);	out.res1 = sqrt((double) in.arg1);	Door_return((char *) &out, sizeof(out), NULL, 0);}/* end servproc *//* include main */intmain(int argc, char **argv){	int	fd;	if (argc != 1)		err_quit("usage: server7");	fd = Door_create(squareproc, NULL, 0);	unlink(PATH_SQUARE_DOOR);	Close(Open(PATH_SQUARE_DOOR, O_CREAT | O_RDWR, FILE_MODE));	Fattach(fd, PATH_SQUARE_DOOR);	fd = Door_create(sqrtproc, NULL, 0);	unlink(PATH_SQRT_DOOR);	Close(Open(PATH_SQRT_DOOR, O_CREAT | O_RDWR, FILE_MODE));	Fattach(fd, PATH_SQRT_DOOR);	for ( ; ; )		pause();}/* end main */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -