亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? proc.c

?? 操作系統課程設計 在minix3下實現實時進程
?? C
?? 第 1 頁 / 共 2 頁
字號:
/* This file contains essentially all of the process and message handling. * Together with "mpx.s" it forms the lowest layer of the MINIX kernel. * There is one entry point from the outside: * *   sys_call: 	      a system call, i.e., the kernel is trapped with an INT * * As well as several entry points used from the interrupt and task level: * *   lock_notify:     notify a process of a system event *   lock_send:	      send a message to a process *   lock_enqueue:    put a process on one of the scheduling queues  *   lock_dequeue:    remove a process from the scheduling queues * * Changes: *   Aug 19, 2005     rewrote scheduling code  (Jorrit N. Herder) *   Jul 25, 2005     rewrote system call handling  (Jorrit N. Herder) *   May 26, 2005     rewrote message passing functions  (Jorrit N. Herder) *   May 24, 2005     new notification system call  (Jorrit N. Herder) *   Oct 28, 2004     nonblocking send and receive calls  (Jorrit N. Herder) * * The code here is critical to make everything work and is important for the * overall performance of the system. A large fraction of the code deals with * list manipulation. To make this both easy to understand and fast to execute  * pointer pointers are used throughout the code. Pointer pointers prevent * exceptions for the head or tail of a linked list.  * *  node_t *queue, *new_node;	// assume these as global variables *  node_t **xpp = &queue; 	// get pointer pointer to head of queue  *  while (*xpp != NULL) 	// find last pointer of the linked list *      xpp = &(*xpp)->next;	// get pointer to next pointer  *  *xpp = new_node;		// now replace the end (the NULL pointer)  *  new_node->next = NULL;	// and mark the new end of the list *  * For example, when adding a new node to the end of the list, one normally  * makes an exception for an empty list and looks up the end of the list for  * nonempty lists. As shown above, this is not required with pointer pointers. */#include <minix/com.h>#include <minix/callnr.h>#include "kernel.h"#include "proc.h"/* Scheduling and message passing functions. The functions are available to  * other parts of the kernel through lock_...(). The lock temporarily disables  * interrupts to prevent race conditions.  */FORWARD _PROTOTYPE( int mini_send, (struct proc *caller_ptr, int dst,		message *m_ptr, unsigned flags));FORWARD _PROTOTYPE( int mini_receive, (struct proc *caller_ptr, int src,		message *m_ptr, unsigned flags));FORWARD _PROTOTYPE( int mini_notify, (struct proc *caller_ptr, int dst));FORWARD _PROTOTYPE( int deadlock, (int function,		register struct proc *caller, int src_dst));FORWARD _PROTOTYPE( void enqueue, (struct proc *rp));FORWARD _PROTOTYPE( void dequeue, (struct proc *rp));FORWARD _PROTOTYPE( void sched, (struct proc *rp, int *queue, int *front));FORWARD _PROTOTYPE( void pick_proc, (void));#define BuildMess(m_ptr, src, dst_ptr) \	(m_ptr)->m_source = (src); 					\	(m_ptr)->m_type = NOTIFY_FROM(src);				\	(m_ptr)->NOTIFY_TIMESTAMP = get_uptime();			\	switch (src) {							\	case HARDWARE:							\		(m_ptr)->NOTIFY_ARG = priv(dst_ptr)->s_int_pending;	\		priv(dst_ptr)->s_int_pending = 0;			\		break;							\	case SYSTEM:							\		(m_ptr)->NOTIFY_ARG = priv(dst_ptr)->s_sig_pending;	\		priv(dst_ptr)->s_sig_pending = 0;			\		break;							\	}#if (CHIP == INTEL)#define CopyMess(s,sp,sm,dp,dm) \	cp_mess(s, (sp)->p_memmap[D].mem_phys,	\		 (vir_bytes)sm, (dp)->p_memmap[D].mem_phys, (vir_bytes)dm)#endif /* (CHIP == INTEL) */#if (CHIP == M68000)/* M68000 does not have cp_mess() in assembly like INTEL. Declare prototype * for cp_mess() here and define the function below. Also define CopyMess.  */#endif /* (CHIP == M68000) *//*===========================================================================* *				sys_call				     *  *===========================================================================*/PUBLIC int sys_call(call_nr, src_dst, m_ptr)int call_nr;			/* system call number and flags */int src_dst;			/* src to receive from or dst to send to */message *m_ptr;			/* pointer to message in the caller's space */{/* System calls are done by trapping to the kernel with an INT instruction. * The trap is caught and sys_call() is called to send or receive a message * (or both). The caller is always given by 'proc_ptr'. */  register struct proc *caller_ptr = proc_ptr;	/* get pointer to caller */  int function = call_nr & SYSCALL_FUNC;	/* get system call function */  unsigned flags = call_nr & SYSCALL_FLAGS;	/* get flags */  int mask_entry;				/* bit to check in send mask */  int group_size;				/* used for deadlock check */  int result;					/* the system call's result */  vir_clicks vlo, vhi;		/* virtual clicks containing message to send */  /* Check if the process has privileges for the requested call. Calls to the    * kernel may only be SENDREC, because tasks always reply and may not block    * if the caller doesn't do receive().    */  if (! (priv(caller_ptr)->s_trap_mask & (1 << function)) ||           (iskerneln(src_dst) && function != SENDREC           && function != RECEIVE)) { #if DEBUG_ENABLE_IPC_WARNINGS      kprintf("sys_call: trap %d not allowed, caller %d, src_dst %d\n",           function, proc_nr(caller_ptr), src_dst);#endif      return(ETRAPDENIED);		/* trap denied by mask or kernel */  }    /* Require a valid source and/ or destination process, unless echoing. */  if (src_dst != ANY && function != ECHO) {      if (! isokprocn(src_dst)) { #if DEBUG_ENABLE_IPC_WARNINGS          kprintf("sys_call: invalid src_dst, src_dst %d, caller %d\n",               src_dst, proc_nr(caller_ptr));#endif          return(EBADSRCDST);		/* invalid process number */      }      if (isemptyn(src_dst)) {#if DEBUG_ENABLE_IPC_WARNINGS          kprintf("sys_call: dead src_dst; trap %d, from %d, to %d\n",               function, proc_nr(caller_ptr), src_dst);#endif	  return(EDEADSRCDST);      }  }  /* If the call involves a message buffer, i.e., for SEND, RECEIVE, SENDREC,    * or ECHO, check the message pointer. This check allows a message to be    * anywhere in data or stack or gap. It will have to be made more elaborate    * for machines which don't have the gap mapped.    */  if (function & CHECK_PTR) {	      vlo = (vir_bytes) m_ptr >> CLICK_SHIFT;		      vhi = ((vir_bytes) m_ptr + MESS_SIZE - 1) >> CLICK_SHIFT;      if (vlo < caller_ptr->p_memmap[D].mem_vir || vlo > vhi ||              vhi >= caller_ptr->p_memmap[S].mem_vir +               caller_ptr->p_memmap[S].mem_len) {#if DEBUG_ENABLE_IPC_WARNINGS          kprintf("sys_call: invalid message pointer, trap %d, caller %d\n",          	function, proc_nr(caller_ptr));#endif          return(EFAULT); 		/* invalid message pointer */      }  }  /* If the call is to send to a process, i.e., for SEND, SENDREC or NOTIFY,   * verify that the caller is allowed to send to the given destination.    */  if (function & CHECK_DST) {	      if (! get_sys_bit(priv(caller_ptr)->s_ipc_to, nr_to_id(src_dst))) {#if DEBUG_ENABLE_IPC_WARNINGS          kprintf("sys_call: ipc mask denied trap %d from %d to %d\n",          	function, proc_nr(caller_ptr), src_dst);#endif          return(ECALLDENIED);		/* call denied by ipc mask */      }  }  /* Check for a possible deadlock for blocking SEND(REC) and RECEIVE. */  if (function & CHECK_DEADLOCK) {      if (group_size = deadlock(function, caller_ptr, src_dst)) {#if DEBUG_ENABLE_IPC_WARNINGS          kprintf("sys_call: trap %d from %d to %d deadlocked, group size %d\n",              function, proc_nr(caller_ptr), src_dst, group_size);#endif          return(ELOCKED);      }  }  /* Now check if the call is known and try to perform the request. The only   * system calls that exist in MINIX are sending and receiving messages.   *   - SENDREC: combines SEND and RECEIVE in a single system call   *   - SEND:    sender blocks until its message has been delivered   *   - RECEIVE: receiver blocks until an acceptable message has arrived   *   - NOTIFY:  nonblocking call; deliver notification or mark pending   *   - ECHO:    nonblocking call; directly echo back the message    */  switch(function) {  case SENDREC:      /* A flag is set so that notifications cannot interrupt SENDREC. */      priv(caller_ptr)->s_flags |= SENDREC_BUSY;      /* fall through */  case SEND:			      result = mini_send(caller_ptr, src_dst, m_ptr, flags);      if (function == SEND || result != OK) {	          break;				/* done, or SEND failed */      }						/* fall through for SENDREC */  case RECEIVE:			      if (function == RECEIVE)          priv(caller_ptr)->s_flags &= ~SENDREC_BUSY;      result = mini_receive(caller_ptr, src_dst, m_ptr, flags);      break;  case NOTIFY:      result = mini_notify(caller_ptr, src_dst);      break;  case ECHO:      CopyMess(caller_ptr->p_nr, caller_ptr, m_ptr, caller_ptr, m_ptr);      result = OK;      break;  default:      result = EBADCALL;			/* illegal system call */  }  /* Now, return the result of the system call to the caller. */  return(result);}/*===========================================================================* *				deadlock				     *  *===========================================================================*/PRIVATE int deadlock(function, cp, src_dst) int function;					/* trap number */register struct proc *cp;			/* pointer to caller */register int src_dst;				/* src or dst process */{/* Check for deadlock. This can happen if 'caller_ptr' and 'src_dst' have * a cyclic dependency of blocking send and receive calls. The only cyclic  * depency that is not fatal is if the caller and target directly SEND(REC) * and RECEIVE to each other. If a deadlock is found, the group size is  * returned. Otherwise zero is returned.  */  register struct proc *xp;			/* process pointer */  int group_size = 1;				/* start with only caller */  int trap_flags;  while (src_dst != ANY) { 			/* check while process nr */      xp = proc_addr(src_dst);			/* follow chain of processes */      group_size ++;				/* extra process in group */      /* Check whether the last process in the chain has a depency. If it        * has not, the cycle cannot be closed and we are done.       */      if (xp->p_rts_flags & RECEIVING) {	/* xp has dependency */          src_dst = xp->p_getfrom;		/* get xp's source */      } else if (xp->p_rts_flags & SENDING) {	/* xp has dependency */          src_dst = xp->p_sendto;		/* get xp's destination */      } else {	  return(0);				/* not a deadlock */      }      /* Now check if there is a cyclic dependency. For group sizes of two,         * a combination of SEND(REC) and RECEIVE is not fatal. Larger groups       * or other combinations indicate a deadlock.         */      if (src_dst == proc_nr(cp)) {		/* possible deadlock */	  if (group_size == 2) {		/* caller and src_dst */	      /* The function number is magically converted to flags. */	      if ((xp->p_rts_flags ^ (function << 2)) & SENDING) { 	          return(0);			/* not a deadlock */	      }	  }          return(group_size);			/* deadlock found */      }  }  return(0);					/* not a deadlock */}/*===========================================================================* *				mini_send				     *  *===========================================================================*/PRIVATE int mini_send(caller_ptr, dst, m_ptr, flags)register struct proc *caller_ptr;	/* who is trying to send a message? */int dst;				/* to whom is message being sent? */message *m_ptr;				/* pointer to message buffer */unsigned flags;				/* system call flags */{/* Send a message from 'caller_ptr' to 'dst'. If 'dst' is blocked waiting * for this message, copy the message to it and unblock 'dst'. If 'dst' is * not waiting at all, or is waiting for another source, queue 'caller_ptr'. */  register struct proc *dst_ptr = proc_addr(dst);  register struct proc **xpp;  /* Check if 'dst' is blocked waiting for this message. The destination's    * SENDING flag may be set when its SENDREC call blocked while sending.     */  if ( (dst_ptr->p_rts_flags & (RECEIVING | SENDING)) == RECEIVING &&       (dst_ptr->p_getfrom == ANY || dst_ptr->p_getfrom == caller_ptr->p_nr)) {	/* Destination is indeed waiting for this message. */	CopyMess(caller_ptr->p_nr, caller_ptr, m_ptr, dst_ptr,		 dst_ptr->p_messbuf);	if ((dst_ptr->p_rts_flags &= ~RECEIVING) == 0) enqueue(dst_ptr);  } else if ( ! (flags & NON_BLOCKING)) {	/* Destination is not waiting.  Block and dequeue caller. */	caller_ptr->p_messbuf = m_ptr;	if (caller_ptr->p_rts_flags == 0) dequeue(caller_ptr);	caller_ptr->p_rts_flags |= SENDING;	caller_ptr->p_sendto = dst;	/* Process is now blocked.  Put in on the destination's queue. */	xpp = &dst_ptr->p_caller_q;		/* find end of list */	while (*xpp != NIL_PROC) xpp = &(*xpp)->p_q_link;		*xpp = caller_ptr;			/* add caller to end */	caller_ptr->p_q_link = NIL_PROC;	/* mark new end of list */  } else {	return(ENOTREADY);  }  return(OK);}/*===========================================================================* *				mini_receive				     *  *===========================================================================*/PRIVATE int mini_receive(caller_ptr, src, m_ptr, flags)register struct proc *caller_ptr;	/* process trying to get message */int src;				/* which message source is wanted */message *m_ptr;				/* pointer to message buffer */unsigned flags;				/* system call flags */{/* A process or task wants to get a message.  If a message is already queued, * acquire it and deblock the sender.  If no message from the desired source * is available block the caller, unless the flags don't allow blocking.   */  register struct proc **xpp;  register struct notification **ntf_q_pp;  message m;  int bit_nr;  sys_map_t *map;  bitchunk_t *chunk;  int i, src_id, src_proc_nr;  /* Check to see if a message from desired source is already available.   * The caller's SENDING flag may be set if SENDREC couldn't send. If it is   * set, the process should be blocked.   */  if (!(caller_ptr->p_rts_flags & SENDING)) {    /* Check if there are pending notifications, except for SENDREC. */    if (! (priv(caller_ptr)->s_flags & SENDREC_BUSY)) {        map = &priv(caller_ptr)->s_notify_pending;        for (chunk=&map->chunk[0]; chunk<&map->chunk[NR_SYS_CHUNKS]; chunk++) {            /* Find a pending notification from the requested source. */             if (! *chunk) continue; 			/* no bits in chunk */            for (i=0; ! (*chunk & (1<<i)); ++i) {} 	/* look up the bit */            src_id = (chunk - &map->chunk[0]) * BITCHUNK_BITS + i;            if (src_id >= NR_SYS_PROCS) break;		/* out of range */            src_proc_nr = id_to_nr(src_id);		/* get source proc */#if DEBUG_ENABLE_IPC_WARNINGS	    if(src_proc_nr == NONE) {		kprintf("mini_receive: sending notify from NONE\n");	    }#endif            if (src!=ANY && src!=src_proc_nr) continue;	/* source not ok */            *chunk &= ~(1 << i);			/* no longer pending */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人黄色小视频在线观看| 欧美高清视频一二三区| 国产女主播在线一区二区| 狠狠色狠狠色综合| 日韩午夜av电影| 日本伊人午夜精品| 欧美精品一卡二卡| 亚洲国产va精品久久久不卡综合 | 激情综合色综合久久| 欧美一区二区三区性视频| 五月婷婷久久综合| 91精品欧美综合在线观看最新 | 亚洲国产成人av网| 欧美日韩一区在线| 日韩精品一卡二卡三卡四卡无卡| 欧美久久免费观看| 日本怡春院一区二区| 欧美不卡一区二区三区四区| 韩国精品在线观看| 国产欧美日韩视频在线观看| 成人一道本在线| 亚洲日本电影在线| 欧美性受极品xxxx喷水| 午夜精品久久久久久不卡8050| 5566中文字幕一区二区电影| 青草国产精品久久久久久| 日韩美女在线视频| 国产精品乡下勾搭老头1| 欧美国产一区视频在线观看| 成人99免费视频| 一区二区高清视频在线观看| 欧美日韩三级视频| 久久精品国产亚洲高清剧情介绍 | 久久久久久久精| 成人激情文学综合网| 成人欧美一区二区三区视频网页 | 欧美电影影音先锋| 美女诱惑一区二区| 国产欧美日韩不卡免费| 色综合久久99| 日本aⅴ亚洲精品中文乱码| 欧美sm美女调教| 成人av动漫在线| 午夜视频久久久久久| 久久久久久久网| 91黄视频在线观看| 欧美aaaaaa午夜精品| 亚洲国产精品精华液ab| 色美美综合视频| 日韩精品电影一区亚洲| 久久久久88色偷偷免费| 在线日韩一区二区| 国产又粗又猛又爽又黄91精品| 国产精品大尺度| 欧美人妖巨大在线| 国产成+人+日韩+欧美+亚洲 | 国产三级精品视频| 91精品福利在线| 狠狠久久亚洲欧美| 亚洲激情自拍视频| 精品国产一区二区三区久久久蜜月| 成av人片一区二区| 三级精品在线观看| 国产精品视频在线看| 欧美日韩视频不卡| 成人午夜免费电影| 日韩在线一区二区| 国产精品成人网| 91精品国产91久久久久久一区二区 | 亚洲欧美国产三级| 日韩欧美成人激情| 91在线观看视频| 毛片av一区二区| 亚洲美女在线国产| 亚洲精品在线观| 欧美日韩一区二区三区四区五区| 国产一区不卡在线| 亚洲高清免费视频| 国产精品视频第一区| 日韩一区二区免费高清| 色婷婷av一区| 国产精品白丝jk白祙喷水网站| 午夜一区二区三区视频| 国产精品久久久久久久蜜臀| 日韩一级精品视频在线观看| 91在线视频免费91| 国产一区二区在线观看免费| 亚洲电影欧美电影有声小说| 国产精品成人网| 久久午夜免费电影| 91超碰这里只有精品国产| 99精品1区2区| 国产精品夜夜爽| 老司机一区二区| 午夜一区二区三区视频| 成人免费在线视频观看| 欧美videos大乳护士334| 欧美日韩精品三区| 色综合久久久久综合| 成人一级视频在线观看| 国产一区啦啦啦在线观看| 日本伊人色综合网| 亚洲成a人片在线不卡一二三区| 中文字幕亚洲成人| 日本一区二区三区四区在线视频| 欧美电影免费观看完整版| 欧美日韩精品一区二区在线播放| 色综合夜色一区| 成人av网址在线| 成人午夜短视频| 国产精品主播直播| 激情欧美一区二区三区在线观看| 三级在线观看一区二区| 一级精品视频在线观看宜春院| 亚洲国产高清aⅴ视频| 国产亚洲一区二区三区在线观看| 亚洲精品一区二区在线观看| 日韩免费成人网| 日韩欧美国产一区在线观看| 91精品国产综合久久久久久久 | 午夜久久福利影院| 亚洲一区二区在线观看视频 | 成人一级黄色片| 丁香婷婷深情五月亚洲| 国产精品一级黄| 东方aⅴ免费观看久久av| 国产精品一二三区| 国产mv日韩mv欧美| 粉嫩高潮美女一区二区三区| 国产精品一卡二卡| 国产suv精品一区二区883| 高清不卡在线观看av| 高清成人免费视频| 不卡一区二区中文字幕| 91原创在线视频| 色乱码一区二区三区88| 欧美自拍偷拍一区| 欧美日韩国产a| 日韩一区二区在线看片| 精品国产免费一区二区三区四区 | 972aa.com艺术欧美| 91蝌蚪porny成人天涯| 色婷婷激情综合| 欧美日本韩国一区| 日韩午夜激情免费电影| 欧美精品一区二| 国产精品素人一区二区| 亚洲欧美另类综合偷拍| 亚洲高清不卡在线| 日本大胆欧美人术艺术动态| 老司机免费视频一区二区| 国产九色精品成人porny| 粉嫩嫩av羞羞动漫久久久| 91丝袜美腿高跟国产极品老师 | 亚洲小说欧美激情另类| 调教+趴+乳夹+国产+精品| 美女视频黄频大全不卡视频在线播放| 久久99国内精品| 高清不卡一二三区| 在线视频欧美区| 日韩视频在线你懂得| 国产亚洲va综合人人澡精品 | 国产精品美女久久久久aⅴ| 一区二区三区在线视频观看58 | 美女高潮久久久| 亚洲欧美在线aaa| 亚洲国产日韩一级| 开心九九激情九九欧美日韩精美视频电影| 久久精品国产第一区二区三区| 国产精品一区二区果冻传媒| 91在线精品一区二区| 秋霞av亚洲一区二区三| 一区二区不卡在线播放| 午夜欧美一区二区三区在线播放| 日本怡春院一区二区| 国产99久久久国产精品| 91日韩在线专区| 宅男噜噜噜66一区二区66| 久久婷婷色综合| 中文字幕一区三区| 视频一区视频二区在线观看| 麻豆精品视频在线观看视频| 国产精品99久久久久久久女警| 91啪亚洲精品| 精品国产99国产精品| 中文字幕一区二区不卡| 日韩中文字幕一区二区三区| 国产盗摄一区二区三区| 欧美在线小视频| 国产女主播视频一区二区| 午夜精品福利视频网站| 高清免费成人av| 欧美一区二区三区白人| 亚洲青青青在线视频| 九九精品视频在线看| 在线区一区二视频| 国产精品乱人伦| 久久99这里只有精品| 日本高清不卡aⅴ免费网站| 久久久影视传媒|