!C99Shell v. 1.0 pre-release build #13!

Software: Apache/2.0.54 (Unix) mod_perl/1.99_09 Perl/v5.8.0 mod_ssl/2.0.54 OpenSSL/0.9.7l DAV/2 FrontPage/5.0.2.2635 PHP/4.4.0 mod_gzip/2.0.26.1a 

uname -a: Linux snow.he.net 4.4.276-v2-mono-1 #1 SMP Wed Jul 21 11:21:17 PDT 2021 i686 

uid=99(nobody) gid=98(nobody) groups=98(nobody) 

Safe-mode: OFF (not secure)

/usr/src/linux-2.4.18-xfs-1.1/arch/ppc/kernel/   drwxr-xr-x
Free 318.38 GB of 458.09 GB (69.5%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Feedback    Self remove    Logout    


Viewing file:     semaphore.c (3.5 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
/*
 * BK Id: SCCS/s.semaphore.c 1.12 05/17/01 18:14:22 cort
 */
/*
 * PowerPC-specific semaphore code.
 *
 * Copyright (C) 1999 Cort Dougan <cort@cs.nmt.edu>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version
 * 2 of the License, or (at your option) any later version.
 *
 * April 2001 - Reworked by Paul Mackerras <paulus@samba.org>
 * to eliminate the SMP races in the old version between the updates
 * of `count' and `waking'.  Now we use negative `count' values to
 * indicate that some process(es) are waiting for the semaphore.
 */

#include <linux/sched.h>
#include <asm/atomic.h>
#include <asm/semaphore.h>

/*
 * Atomically update sem->count.
 * This does the equivalent of the following:
 *
 *    old_count = sem->count;
 *    tmp = MAX(old_count, 0) + incr;
 *    sem->count = tmp;
 *    return old_count;
 */
static inline int __sem_update_count(struct semaphore *sem, int incr)
{
    int old_count, tmp;

    __asm__ __volatile__("\n"
"1:    lwarx    %0,0,%3\n"
"    srawi    %1,%0,31\n"
"    andc    %1,%0,%1\n"
"    add    %1,%1,%4\n"
"    stwcx.    %1,0,%3\n"
"    bne    1b"
    : "=&r" (old_count), "=&r" (tmp), "=m" (sem->count)
    : "r" (&sem->count), "r" (incr), "m" (sem->count)
    : "cc");

    return old_count;
}

void __up(struct semaphore *sem)
{
    /*
     * Note that we incremented count in up() before we came here,
     * but that was ineffective since the result was <= 0, and
     * any negative value of count is equivalent to 0.
     * This ends up setting count to 1, unless count is now > 0
     * (i.e. because some other cpu has called up() in the meantime),
     * in which case we just increment count.
     */
    __sem_update_count(sem, 1);
    wake_up(&sem->wait);
}

/*
 * Note that when we come in to __down or __down_interruptible,
 * we have already decremented count, but that decrement was
 * ineffective since the result was < 0, and any negative value
 * of count is equivalent to 0.
 * Thus it is only when we decrement count from some value > 0
 * that we have actually got the semaphore.
 */
void __down(struct semaphore *sem)
{
    struct task_struct *tsk = current;
    DECLARE_WAITQUEUE(wait, tsk);

    tsk->state = TASK_UNINTERRUPTIBLE;
    add_wait_queue_exclusive(&sem->wait, &wait);
    smp_wmb();

    /*
     * Try to get the semaphore.  If the count is > 0, then we've
     * got the semaphore; we decrement count and exit the loop.
     * If the count is 0 or negative, we set it to -1, indicating
     * that we are asleep, and then sleep.
     */
    while (__sem_update_count(sem, -1) <= 0) {
        schedule();
        tsk->state = TASK_UNINTERRUPTIBLE;
    }
    remove_wait_queue(&sem->wait, &wait);
    tsk->state = TASK_RUNNING;

    /*
     * If there are any more sleepers, wake one of them up so
     * that it can either get the semaphore, or set count to -1
     * indicating that there are still processes sleeping.
     */
    wake_up(&sem->wait);
}

int __down_interruptible(struct semaphore * sem)
{
    int retval = 0;
    struct task_struct *tsk = current;
    DECLARE_WAITQUEUE(wait, tsk);

    tsk->state = TASK_INTERRUPTIBLE;
    add_wait_queue_exclusive(&sem->wait, &wait);
    smp_wmb();

    while (__sem_update_count(sem, -1) <= 0) {
        if (signal_pending(current)) {
            /*
             * A signal is pending - give up trying.
             * Set sem->count to 0 if it is negative,
             * since we are no longer sleeping.
             */
            __sem_update_count(sem, 0);
            retval = -EINTR;
            break;
        }
        schedule();
        tsk->state = TASK_INTERRUPTIBLE;
    }
    tsk->state = TASK_RUNNING;
    remove_wait_queue(&sem->wait, &wait);
    wake_up(&sem->wait);
    return retval;
}

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

:: Make Dir ::
 
[ Read-Only ]
:: Make File ::
 
[ Read-Only ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 1.0 pre-release build #13 powered by Captain Crunch Security Team | http://ccteam.ru | Generation time: 0.011 ]--