import svipc import sys import time # retreive ids my_shmid,my_semid,my_msqid = [int(a) for a in sys.argv[1:]] # wait one sec #let yorick wait .. time.sleep(1) # tell it to go svipc.sem_give(my_semid,id=0) # play 1 for i in range(3): time.sleep(1) svipc.sem_give(key=my_semid,id=0) # play 2 svipc.sem_take(my_semid,0) for i in range(3): msg = svipc.shm_read(my_shmid,id="pingpong",subscribe=-1.0) time.sleep(1) msg[i]=0
def child(self): for i in range(10): sem_give(sid, 0)
def child(self): sem_give(sid, 0)
def child(self): sem_give(sid,0)
def child(self): sleep(delay) sem_give(sid, 0)
def child(self): for i in range(10): sem_give(sid,0)
def child(self): sleep(delay) sem_give(sid,0)
#! /usr/bin/env python import svipc import sys import time # retreive ids my_shmid, my_semid, my_msqid = [int(a) for a in sys.argv[1:]] #let yorick wait .. for fun sys.stderr.write('P: sleeping 1s.\n') time.sleep(1) # tell it to go sys.stderr.write('P: yorick may go.\n') svipc.sem_give(my_semid, id=0) # play 1 for i in range(3): time.sleep(1) sys.stderr.write('P: sem give %d.\n' % i) svipc.sem_give(key=my_semid, id=0) # play 2 sys.stderr.write('P: wait synch from yorick\n') svipc.sem_take(my_semid, 1) sys.stderr.write('P: going now\n')
n = 32 stoopid=numpy.ones(n) stoopid[n-1]=n data = numpy.arange(n).reshape(stoopid) #print data.shape # create id svid0 = 0x7dcb0000 | getpid() svid1 = svid0+1 # create a pool with one shmaphore shm_init(svid0,slots=1) sem_init(svid1,nums=1) if fork(): for i in range(num_): shm_write(svid0,'slot0',data,publish=0) # shm id's are string ... doh sem_take(svid1,0) else: time.sleep(1) for i in range(num_): d=shm_read(svid0,'slot0',0) sem_give(svid1,0) ### print d exit() sem_cleanup(svid1) shm_cleanup(svid0)
n = 32 stoopid = numpy.ones(n) stoopid[n - 1] = n data = numpy.arange(n).reshape(stoopid) #print data.shape # create id svid0 = 0x7dcb0000 | getpid() svid1 = svid0 + 1 # create a pool with one shmaphore shm_init(svid0, slots=1) sem_init(svid1, nums=1) if fork(): for i in range(num_): shm_write(svid0, 'slot0', data, publish=0) # shm id's are string ... doh sem_take(svid1, 0) else: time.sleep(1) for i in range(num_): d = shm_read(svid0, 'slot0', 0) sem_give(svid1, 0) ### print d exit() sem_cleanup(svid1) shm_cleanup(svid0)