Example #1
0
func (m *Mutex) unlock() {
	unlocked := m.state &^ 1
	barrier.Memory()
	if atomic.AddUintptr(&m.state, ^uintptr(0)) != unlocked {
		panic("sync: unlock of unlocked mutex")
	}
	noos.Event(unlocked).Send()
}
Example #2
0
func (t *terminal) Write(b []byte) (n int, _ error) {
	for len(b) != 0 {
		t.waittx()
		m := copy(t.txbuf[:], b)
		barrier.Memory()
		t.siz.tx = byte(m)

		n += m
		b = b[m:]
	}
	return
}
Example #3
0
func sysTickHandler() {
	aba := atomic.LoadUintptr(&ticksABA)
	t := ticks[aba&1]
	aba++
	ticks[aba&1] = t + 1
	barrier.Memory()
	atomic.StoreUintptr(&ticksABA, aba)
	tickEvent.Send()

	if tasker.onSysTick {
		exce.PendSV.SetPending()
	}
}
Example #4
0
func (t *terminal) Read(b []byte) (n int, _ error) {
	t.waitrx()

	n = copy(b, t.rxbuf[t.rd:t.siz.rx])
	t.rd += n

	if t.rd == int(t.siz.rx) {
		barrier.Memory()
		t.siz.rx = 0
		t.rd = 0
	}
	return
}
Example #5
0
func (t *terminal) WriteString(s string) (n int, _ error) {
	//b := (*[]byte)(unsafe.Pointer(&s))
	//return t.Write((*b)[:len(s):len(s)])

	for len(s) != 0 {
		t.waittx()
		m := copy(t.txbuf[:], s)
		barrier.Memory()
		t.siz.tx = byte(m)

		n += m
		s = s[m:]
	}
	return
}
Example #6
0
func (ts *taskSched) stop() {
	ts.onSysTick = false
	barrier.Memory()
}
Example #7
0
func (ts *taskSched) run() {
	barrier.Memory()
	ts.onSysTick = true
}
Example #8
0
// UseTable instructs CPU to use vt as vector table. vt should be properly
// aligned. Minimum alignment is 32 words which is enough for up to 16 external
// interrupts. For more interrupts, adjust the alignment by rounding up to the
// next power of two. UseTable doesn't work for Cortex-M0.
//
// This function is designed to be used by runtime. You generaly shouldn't use
// it if MaxTask > 0 in your linker script.
func UseTable(vt []Vector) {
	activeVT = vt
	barrier.Memory()
	vto.Store(uint32(uintptr(unsafe.Pointer(&vt[0]))))
}
Example #9
0
func (c *chanS) unlock() {
	barrier.Memory()
	atomic.CompareAndSwapInt32(&c.state, 1, 0)
	c.event.Send()
}
Example #10
0
// Done must be called after the data transfer was completed.
func (c *chanS) Done(d uintptr) {
	barrier.Memory()
	atomic.StorePointer((*unsafe.Pointer)(unsafe.Pointer(d)), nil)
	c.event.Send()
}