Print this page
patch as-lock-macro-simplification


2496                                 watch_disable(t);
2497 
2498                         } while ((t = t->t_forw) != p->p_tlist);
2499                 }
2500         }
2501 
2502         if ((as = p->p_as) != NULL) {
2503                 avl_tree_t *tree;
2504                 struct watched_page *pwp;
2505 
2506                 /*
2507                  * If this is the parent of a vfork, the watched page
2508                  * list has been moved temporarily to p->p_wpage.
2509                  */
2510                 if (avl_numnodes(&p->p_wpage) != 0)
2511                         tree = &p->p_wpage;
2512                 else
2513                         tree = &as->a_wpage;
2514 
2515                 mutex_exit(&p->p_lock);
2516                 AS_LOCK_ENTER(as, &as->a_lock, RW_WRITER);
2517 
2518                 for (pwp = avl_first(tree); pwp != NULL;
2519                     pwp = AVL_NEXT(tree, pwp)) {
2520                         pwp->wp_read = 0;
2521                         pwp->wp_write = 0;
2522                         pwp->wp_exec = 0;
2523                         if ((pwp->wp_flags & WP_SETPROT) == 0) {
2524                                 pwp->wp_flags |= WP_SETPROT;
2525                                 pwp->wp_prot = pwp->wp_oprot;
2526                                 pwp->wp_list = p->p_wprot;
2527                                 p->p_wprot = pwp;
2528                         }
2529                 }
2530 
2531                 AS_LOCK_EXIT(as, &as->a_lock);
2532                 mutex_enter(&p->p_lock);
2533         }
2534 
2535         /*
2536          * Unpause the process now.
2537          */
2538         if (p == curproc)
2539                 continuelwps(p);
2540         else
2541                 unpauselwps(p);
2542 
2543         return (p);
2544 }


2496                                 watch_disable(t);
2497 
2498                         } while ((t = t->t_forw) != p->p_tlist);
2499                 }
2500         }
2501 
2502         if ((as = p->p_as) != NULL) {
2503                 avl_tree_t *tree;
2504                 struct watched_page *pwp;
2505 
2506                 /*
2507                  * If this is the parent of a vfork, the watched page
2508                  * list has been moved temporarily to p->p_wpage.
2509                  */
2510                 if (avl_numnodes(&p->p_wpage) != 0)
2511                         tree = &p->p_wpage;
2512                 else
2513                         tree = &as->a_wpage;
2514 
2515                 mutex_exit(&p->p_lock);
2516                 AS_LOCK_ENTER(as, RW_WRITER);
2517 
2518                 for (pwp = avl_first(tree); pwp != NULL;
2519                     pwp = AVL_NEXT(tree, pwp)) {
2520                         pwp->wp_read = 0;
2521                         pwp->wp_write = 0;
2522                         pwp->wp_exec = 0;
2523                         if ((pwp->wp_flags & WP_SETPROT) == 0) {
2524                                 pwp->wp_flags |= WP_SETPROT;
2525                                 pwp->wp_prot = pwp->wp_oprot;
2526                                 pwp->wp_list = p->p_wprot;
2527                                 p->p_wprot = pwp;
2528                         }
2529                 }
2530 
2531                 AS_LOCK_EXIT(as);
2532                 mutex_enter(&p->p_lock);
2533         }
2534 
2535         /*
2536          * Unpause the process now.
2537          */
2538         if (p == curproc)
2539                 continuelwps(p);
2540         else
2541                 unpauselwps(p);
2542 
2543         return (p);
2544 }