예제 #1
0
 def entry_point(argv):
     os.write(1, "hello world\n")
     state.xlist = []
     x2 = Cons(51, Cons(62, Cons(74, None)))
     # start 5 new threads
     state.ll_lock = rthread.allocate_ll_lock()
     after()
     invoke_around_extcall(before, after)
     ident1 = new_thread()
     ident2 = new_thread()
     #
     gc.collect()
     #
     ident3 = new_thread()
     ident4 = new_thread()
     ident5 = new_thread()
     # wait for the 5 threads to finish
     while True:
         gc.collect()
         if len(state.xlist) == 5:
             break
         time.sleep(0.1)  # invokes before/after
     # check that the malloced structures were not overwritten
     assert x2.head == 51
     assert x2.tail.head == 62
     assert x2.tail.tail.head == 74
     assert x2.tail.tail.tail is None
     # check the structures produced by the threads
     for i in range(5):
         assert state.xlist[i].head == 123
         assert state.xlist[i].tail.head == 456
         assert state.xlist[i].tail.tail is None
         os.write(1, "%d ok\n" % (i + 1))
     return 0
예제 #2
0
 def entry_point(argv):
     os.write(1, "hello world\n")
     error = rthread.set_stacksize(int(argv[1]))
     if error != 0:
         os.write(
             2,
             "set_stacksize(%d) returned %d\n" % (int(argv[1]), error))
         raise AssertionError
     # malloc a bit
     s1 = State()
     s2 = State()
     s3 = State()
     s1.x = 0x11111111
     s2.x = 0x22222222
     s3.x = 0x33333333
     # start 3 new threads
     state.ll_lock = rthread.allocate_ll_lock()
     after()
     state.count = 0
     invoke_around_extcall(before, after)
     ident1 = rthread.start_new_thread(bootstrap, ())
     ident2 = rthread.start_new_thread(bootstrap, ())
     ident3 = rthread.start_new_thread(bootstrap, ())
     # wait for the 3 threads to finish
     while True:
         if state.count == 3:
             break
         time.sleep(0.1)  # invokes before/after
     # check that the malloced structures were not overwritten
     assert s1.x == 0x11111111
     assert s2.x == 0x22222222
     assert s3.x == 0x33333333
     os.write(1, "done\n")
     return 0
예제 #3
0
 def entry_point(argv):
     os.write(1, "hello world\n")
     state.xlist = []
     x2 = Cons(51, Cons(62, Cons(74, None)))
     # start 5 new threads
     state.ll_lock = rthread.allocate_ll_lock()
     after()
     invoke_around_extcall(before, after)
     ident1 = new_thread()
     ident2 = new_thread()
     #
     gc.collect()
     #
     ident3 = new_thread()
     ident4 = new_thread()
     ident5 = new_thread()
     # wait for the 5 threads to finish
     while True:
         gc.collect()
         if len(state.xlist) == 5:
             break
         time.sleep(0.1)      # invokes before/after
     # check that the malloced structures were not overwritten
     assert x2.head == 51
     assert x2.tail.head == 62
     assert x2.tail.tail.head == 74
     assert x2.tail.tail.tail is None
     # check the structures produced by the threads
     for i in range(5):
         assert state.xlist[i].head == 123
         assert state.xlist[i].tail.head == 456
         assert state.xlist[i].tail.tail is None
         os.write(1, "%d ok\n" % (i+1))
     return 0
예제 #4
0
 def entry_point(argv):
     os.write(1, "hello world\n")
     error = rthread.set_stacksize(int(argv[1]))
     if error != 0:
         os.write(2, "set_stacksize(%d) returned %d\n" % (
             int(argv[1]), error))
         raise AssertionError
     # malloc a bit
     s1 = State(); s2 = State(); s3 = State()
     s1.x = 0x11111111; s2.x = 0x22222222; s3.x = 0x33333333
     # start 3 new threads
     state.ll_lock = rthread.allocate_ll_lock()
     after()
     state.count = 0
     invoke_around_extcall(before, after)
     ident1 = rthread.start_new_thread(bootstrap, ())
     ident2 = rthread.start_new_thread(bootstrap, ())
     ident3 = rthread.start_new_thread(bootstrap, ())
     # wait for the 3 threads to finish
     while True:
         if state.count == 3:
             break
         time.sleep(0.1)      # invokes before/after
     # check that the malloced structures were not overwritten
     assert s1.x == 0x11111111
     assert s2.x == 0x22222222
     assert s3.x == 0x33333333
     os.write(1, "done\n")
     return 0
예제 #5
0
 def entry_point(argv):
     os.write(1, "hello world\n")
     state.xlist = []
     state.deleted = 0
     state.read_end, state.write_end = os.pipe()
     x2 = Cons(51, Cons(62, Cons(74, None)))
     # start 5 new threads
     state.ll_lock = rthread.allocate_ll_lock()
     after()
     invoke_around_extcall(before, after)
     start_arthreads()
     # force freeing
     gc.collect()
     gc.collect()
     gc.collect()
     # return everything that was written to the pipe so far,
     # followed by the final dot.
     os.write(state.write_end, '.')
     result = os.read(state.read_end, 256)
     os.write(1, "got: %s\n" % result)
     return 0
예제 #6
0
 def entry_point(argv):
     os.write(1, "hello world\n")
     state.xlist = []
     state.deleted = 0
     state.read_end, state.write_end = os.pipe()
     x2 = Cons(51, Cons(62, Cons(74, None)))
     # start 5 new threads
     state.ll_lock = rthread.allocate_ll_lock()
     after()
     invoke_around_extcall(before, after)
     start_arthreads()
     # force freeing
     gc.collect()
     gc.collect()
     gc.collect()
     # return everything that was written to the pipe so far,
     # followed by the final dot.
     os.write(state.write_end, '.')
     result = os.read(state.read_end, 256)
     os.write(1, "got: %s\n" % result)
     return 0