Exemple #1
0
 def signal_memory_error(self, s_frame):
     w_low_space_sema = self.space.w_low_space_semaphore()
     if w_low_space_sema is not self.space.w_nil:
         assert isinstance(w_low_space_sema, W_PointersObject)
         wrapper.SemaphoreWrapper(self.space,
                                  w_low_space_sema).signal(s_frame,
                                                           forced=True)
Exemple #2
0
    def check_for_interrupts(self, s_frame):
        display = self.space.display()
        if display:
            display.render()

        # parallel to Interpreter>>#checkForInterrupts
        # 1. profiling is done using rvmprof
        # 2. use the same time value as the primitive UTC_MICROSECOND_CLOCK
        now = self.time_now()
        # 3. adjust the check counter size, we want to land between 20ms and 100ms
        diff = now - self.last_check
        if diff < 20000 and self.interrupt_counter_size != constants.MAXINT:
            try:
                self.interrupt_counter_size = ovfcheck(
                    self.interrupt_counter_size * 2)
            except OverflowError:
                self.interrupt_counter_size = constants.MAXINT
        elif diff > 100000 and self.interrupt_counter_size > 100:
            self.interrupt_counter_size = max(self.interrupt_counter_size / 2,
                                              100)
        self.last_check = now
        self.forced_interrupt_checks_count += 1

        # 4. check for User Interrupt
        if self.space.display().has_interrupts_pending():
            w_interrupt_sema = self.space.w_interrupt_semaphore()
            if w_interrupt_sema is not self.space.w_nil:
                assert isinstance(w_interrupt_sema, W_PointersObject)
                wrapper.SemaphoreWrapper(self.space,
                                         w_interrupt_sema).signal(s_frame,
                                                                  forced=True)

        # 5. the low space semaphore is signalled in ClassShadow#new
        # 6. signal the timer
        if not self.next_wakeup_tick == 0 and now >= self.next_wakeup_tick:
            self.next_wakeup_tick = 0
            semaphore = self.space.w_timerSemaphore()
            if not semaphore.is_nil(self.space):
                assert isinstance(semaphore, W_PointersObject)
                wrapper.SemaphoreWrapper(self.space,
                                         semaphore).signal(s_frame,
                                                           forced=False)
Exemple #3
0
def func(interp, s_frame, w_rcvr):
    assert_class(interp, w_rcvr, interp.space.w_Semaphore)
    wrapper.SemaphoreWrapper(interp.space, w_rcvr).wait(s_frame)
Exemple #4
0
def new_semaphore(excess_signals=0):
    w_semaphore = W_PointersObject(space, None, 3)
    semaphore = wrapper.SemaphoreWrapper(space, w_semaphore)
    semaphore.store_excess_signals(excess_signals)
    return semaphore