Changeset 1987 for trunk/src

Timestamp:
May 12, 2005, 1:16:54 AM (21 years ago)
Author:
bird
Message:

shm + sem debuging.

Location:
trunk/src/emx
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/emx/include/InnoTekLIBC/backend.h

    • Property cvs2svn:cvs-rev changed from 1.24 to 1.25
    r1986 r1987  
    3535#include <sys/wait.h>
    3636#include <sys/sem.h>
     37
    3738#include <signal.h>
    3839#include <emx/io.h>
  • trunk/src/emx/include/sys/sem.h

    • Property cvs2svn:cvs-rev changed from 1.3 to 1.4
    r1986 r1987  
    1111 * FreeBSD 5.3
    1212 * @changed     bird: no padding in semid_ds. seminfo and semexit are static in our 'kernel'.
     13
    1314 */
    1415
     
    1718
    1819#include <sys/ipc.h>
     20
     21
     22
     23
     24
     25
     26
     27
     28
     29
     30
     31
     32
     33
     34
     35
     36
     37
     38
     39
     40
    1941
    2042struct sem;
  • trunk/src/emx/include/sys/shm.h

    • Property cvs2svn:cvs-rev changed from 1.3 to 1.4
    r1986 r1987  
    3939/** @file
    4040 * FreeBSD 5.3
    41  * @changed the SHMLBA to 64KB.
     41 * @changed     bird: the SHMLBA to 64KB.
     42 * @changed     bird: added pid_t, time_t and size_t (POSIX).
    4243 */
    4344
     
    4647
    4748#include <sys/ipc.h>
     49
     50
     51
     52
     53
     54
     55
     56
     57
     58
     59
     60
     61
     62
     63
     64
     65
     66
     67
     68
     69
    4870
    4971#define SHM_RDONLY  010000  /* Attach read-only (else read-write) */
  • trunk/src/emx/src/lib/sys/sysv_sem.c

    • Property cvs2svn:cvs-rev changed from 1.2 to 1.3
    r1986 r1987  
    562562        uid_t uid;
    563563        uintptr_t hmtx;
    564 
     564        int semid_in = semid;
    565565
    566566        /*
     
    608608        case IPC_RMID:
    609609                __libc_Back_safesemMtxLock(hmtx = semaptr->hmtx);
    610                 if ((error = semvalid(semid, semaptr)) != 0)
     610                if ((error = semvalid(semid, semaptr)) != 0)
    611611                        goto done2;
    612612                if ((error = -__libc_spmCanIPC(&semaptr->u.sem_perm, IPC_M)))
     
    634634                        goto done2;
    635635                __libc_Back_safesemMtxLock(hmtx = semaptr->hmtx);
    636                 if ((error = semvalid(semid, semaptr)) != 0)
     636                if ((error = semvalid(semid, semaptr)) != 0)
    637637                        goto done2;
    638638                if ((error = -__libc_spmCanIPC(&semaptr->u.sem_perm, IPC_M)))
     
    647647        case IPC_STAT:
    648648                __libc_Back_safesemMtxLock(hmtx = semaptr->hmtx);
    649                 if ((error = semvalid(semid, semaptr)) != 0)
     649                if ((error = semvalid(semid, semaptr)) != 0)
    650650                        goto done2;
    651651                if ((error = -__libc_spmCanIPC(&semaptr->u.sem_perm, IPC_R)))
     
    659659        case GETNCNT:
    660660                __libc_Back_safesemMtxLock(hmtx = semaptr->hmtx);
    661                 if ((error = semvalid(semid, semaptr)) != 0)
     661                if ((error = semvalid(semid, semaptr)) != 0)
    662662                        goto done2;
    663663                if ((error = -__libc_spmCanIPC(&semaptr->u.sem_perm, IPC_R)))
     
    672672        case GETPID:
    673673                __libc_Back_safesemMtxLock(hmtx = semaptr->hmtx);
    674                 if ((error = semvalid(semid, semaptr)) != 0)
     674                if ((error = semvalid(semid, semaptr)) != 0)
    675675                        goto done2;
    676676                if ((error = -__libc_spmCanIPC(&semaptr->u.sem_perm, IPC_R)))
     
    685685        case GETVAL:
    686686                __libc_Back_safesemMtxLock(hmtx = semaptr->hmtx);
    687                 if ((error = semvalid(semid, semaptr)) != 0)
     687                if ((error = semvalid(semid, semaptr)) != 0)
    688688                        goto done2;
    689689                if ((error = -__libc_spmCanIPC(&semaptr->u.sem_perm, IPC_R)))
     
    699699                array = _hmalloc(sizeof(*array) * semaptr->u.sem_nsems);
    700700                __libc_Back_safesemMtxLock(hmtx = semaptr->hmtx);
    701                 if ((error = semvalid(semid, semaptr)) != 0)
     701                if ((error = semvalid(semid, semaptr)) != 0)
    702702                        goto done2;
    703703                if ((error = -__libc_spmCanIPC(&semaptr->u.sem_perm, IPC_R)))
     
    712712        case GETZCNT:
    713713                __libc_Back_safesemMtxLock(hmtx = semaptr->hmtx);
    714                 if ((error = semvalid(semid, semaptr)) != 0)
     714                if ((error = semvalid(semid, semaptr)) != 0)
    715715                        goto done2;
    716716                if ((error = -__libc_spmCanIPC(&semaptr->u.sem_perm, IPC_R)))
     
    725725        case SETVAL:
    726726                __libc_Back_safesemMtxLock(hmtx = semaptr->hmtx);
    727                 if ((error = semvalid(semid, semaptr)) != 0)
     727                if ((error = semvalid(semid, semaptr)) != 0)
    728728                        goto done2;
    729729                if ((error = -__libc_spmCanIPC(&semaptr->u.sem_perm, IPC_W)))
     
    747747                __libc_Back_safesemMtxLock(hmtx = semaptr->hmtx);
    748748raced:
    749                 if ((error = semvalid(semid, semaptr)) != 0)
     749                if ((error = semvalid(semid, semaptr)) != 0)
    750750                        goto done2;
    751751                count = semaptr->u.sem_nsems;
     
    756756                        break;
    757757                __libc_Back_safesemMtxLock(hmtx = semaptr->hmtx);
    758                 if ((error = semvalid(semid, semaptr)) != 0)
     758                if ((error = semvalid(semid, semaptr)) != 0)
    759759                        goto done2;
    760760                /* we could have raced? */
     
    894894
    895895found:
    896         errno = -IXSEQ_TO_IPCID(semid, sema[semid].u.sem_perm);
     896        err = -IXSEQ_TO_IPCID(semid, sema[semid].u.sem_perm);
    897897done2:
    898898        __libc_Back_safesemMtxUnlock(gpGlobals->hmtx);
     
    948948        int error;
    949949        int do_wakeup, do_undos;
     950
    950951
    951952        /*
     
    996997                goto done2;
    997998        }
    998         if (semaptr->u.sem_perm.seq != IPCID_TO_SEQ(semid)) {
     999        if (semaptr->u.sem_perm.seq != IPCID_TO_SEQ(semid)) {
    9991000                error = EINVAL;
    10001001                goto done2;
     
    11151116                 */
    11161117                if ((semaptr->u.sem_perm.mode & SEM_ALLOC) == 0 ||
    1117                     semaptr->u.sem_perm.seq != IPCID_TO_SEQ(semid)) {
     1118                    semaptr->u.sem_perm.seq != IPCID_TO_SEQ(semid)) {
    11181119                        error = EIDRM;
    11191120                        goto done2;
     
    12211222{
    12221223        LIBCLOG_ENTER("\n");
     1224
    12231225        struct sem_undo *suptr;
    12241226        struct sem_undo **supptr;
     
    12271229         * If no pointer to globals then there is nothing to do (nearly impossible).
    12281230         */
    1229         if (!gpGlobals)
     1231        if (!gpGlobals)
    12301232            LIBCLOG_RETURN_VOID();
     1233
    12311234
    12321235        /*
  • trunk/src/emx/src/lib/sys/sysv_shm.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1986 r1987  
    122122#define SHMSEG_ALLOCATED        0x0800
    123123//#define       SHMSEG_WANTED           0x1000 - cannot happen with our locking policy.
     124
     125
     126
    124127
    125128static void shm_deallocate_segment(struct shmid_ds *);
     
    127130static struct shmid_ds *shm_find_segment_by_shmid(int);
    128131static struct shmid_ds *shm_find_segment_by_shmidx(int);
    129 static int shm_delete_mapping(struct shmmap_state *);
     132static int shm_delete_mapping(struct shmmap_state *);
    130133static int shminit(void);
    131134static void shmexit_myhook(void);
     
    287290
    288291static int
    289 shm_delete_mapping(struct shmmap_state *shmmap_s)
     292shm_delete_mapping(struct shmmap_state *shmmap_s)
    290293{
    291294        struct __libc_SysV_Shm *pGlobals = gpGlobals;
     
    306309        shmseg->shm_dtime = fibGetUnixSeconds();
    307310        if ((--shmseg->shm_nattch <= 0) &&
    308             (shmseg->shm_perm.mode & SHMSEG_REMOVED)) {
     311            (   (shmseg->shm_perm.mode & SHMSEG_REMOVED)
     312             || (fExitting && !(shmseg->shm_perm.mode & SHMSEG_SERVER)))) {
    309313                shm_deallocate_segment(shmseg);
    310314                pGlobals->shm_last_free = segnum;
     
    359363                goto done2;
    360364        }
    361         error = shm_delete_mapping(shmmap_s);
     365        error = shm_delete_mapping(shmmap_s);
    362366done2:
    363367        __libc_Back_safesemMtxUnlock(gpGlobals->hmtx);
     
    825829shmexit_myhook(void)
    826830{
     831
    827832        struct __libc_SysV_Shm *pGlobals = gpGlobals;
    828         if (pGlobals) {
    829                 gpGlobals = NULL;
     833        if (pGlobals && !fDone) {
     834                fDone = 1;
     835                __libc_Back_safesemMtxLock(pGlobals->hmtx);
    830836                struct shmmap_state *shm = g_vm_shm;
    831837                if (shm) {
    832838                        g_vm_shm = NULL;
    833                         __libc_Back_safesemMtxLock(pGlobals->hmtx);
    834839                        int c = shminfo.shmseg;
    835840                        while (c-- > 0) {
    836                                 if (shm->shmid != -1)
    837                                         shm_delete_mapping(shm);
     841                                if (shm->shmid != -1) {
     842                                        shm_delete_mapping(shm, 1);
     843                                }
    838844                                shm++;
    839845                        }
    840                         __libc_Back_safesemMtxUnlock(pGlobals->hmtx);
    841846                }
     847
     848
     849
     850
     851
     852
     853
     854
     855
     856
     857
     858
     859
     860
     861
     862
     863
     864
     865
     866
     867
     868
     869
     870
    842871                __atomic_decrement_u32(&pGlobals->cUsers);
     872
    843873        }
    844874}
     
    890920        if (rc)
    891921            LIBCLOG_RETURN_INT(rc);
    892         if (!pSPMHdr->pSysVSem)
     922        if (!pSPMHdr->pSysVSm)
    893923        {
    894924            pGlobals = (struct __libc_SysV_Shm *)__libc_spmAllocLocked(cb);
Note: See TracChangeset for help on using the changeset viewer.