Print this page
XXXX semaphores behavior is inconsistent in panicstr case

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/os/semaphore.c
          +++ new/usr/src/uts/common/os/semaphore.c
↓ open down ↓ 16 lines elided ↑ open up ↑
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  24   24   * Use is subject to license terms.
  25   25   */
  26   26  
  27      -#pragma ident   "%Z%%M% %I%     %E% SMI"
  28      -
  29   27  /*
  30   28   * This file contains the semaphore operations.
  31   29   */
  32   30  
  33   31  #include <sys/param.h>
  34   32  #include <sys/types.h>
  35   33  #include <sys/systm.h>
  36   34  #include <sys/schedctl.h>
  37   35  #include <sys/semaphore.h>
  38   36  #include <sys/sema_impl.h>
↓ open down ↓ 185 lines elided ↑ open up ↑
 224  222  void
 225  223  sema_p(ksema_t *sp)
 226  224  {
 227  225          sema_impl_t     *s;
 228  226          disp_lock_t     *sqlp;
 229  227  
 230  228          s = (sema_impl_t *)sp;
 231  229          sqlp = &SQHASH(s)->sq_lock;
 232  230          disp_lock_enter(sqlp);
 233  231          ASSERT(s->s_count >= 0);
      232 +        if (panicstr) {
      233 +                disp_lock_exit(sqlp);
      234 +                return;
      235 +        }
 234  236          while (s->s_count == 0) {
 235      -                if (panicstr) {
 236      -                        disp_lock_exit(sqlp);
 237      -                        return;
 238      -                }
 239  237                  thread_lock_high(curthread);
 240  238                  SEMA_BLOCK(s, sqlp);
 241  239                  thread_unlock_nopreempt(curthread);
 242  240                  swtch();
 243  241                  disp_lock_enter(sqlp);
 244  242          }
 245  243          s->s_count--;
 246  244          disp_lock_exit(sqlp);
 247  245  }
 248  246  
↓ open down ↓ 120 lines elided ↑ open up ↑
 369  367  sema_tryp(ksema_t *sp)
 370  368  {
 371  369          sema_impl_t     *s;
 372  370          sleepq_head_t   *sqh;
 373  371  
 374  372          int     gotit = 0;
 375  373  
 376  374          s = (sema_impl_t *)sp;
 377  375          sqh = SQHASH(s);
 378  376          disp_lock_enter(&sqh->sq_lock);
      377 +        if (panicstr) {
      378 +                disp_lock_exit(sqlp);
      379 +                return (1);
      380 +        }
 379  381          if (s->s_count > 0) {
 380  382                  s->s_count--;
 381  383                  gotit = 1;
 382  384          }
 383  385          disp_lock_exit(&sqh->sq_lock);
 384  386          return (gotit);
 385  387  }
 386  388  
 387  389  int
 388  390  sema_held(ksema_t *sp)
 389  391  {
 390  392          sema_impl_t     *s;
 391  393  
 392  394  
 393  395          s = (sema_impl_t *)sp;
 394  396          if (panicstr)
 395  397                  return (1);
 396  398          else
 397  399                  return (s->s_count <= 0);
 398  400  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX