示例#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()
}
示例#2
0
文件: terminal.go 项目: rjammala/emgo
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
}
示例#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()
	}
}
示例#4
0
文件: terminal.go 项目: rjammala/emgo
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
}
示例#5
0
文件: terminal.go 项目: rjammala/emgo
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
}
示例#6
0
func (ts *taskSched) stop() {
	ts.onSysTick = false
	barrier.Memory()
}
示例#7
0
func (ts *taskSched) run() {
	barrier.Memory()
	ts.onSysTick = true
}
示例#8
0
文件: vector.go 项目: rjammala/emgo
// 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]))))
}
示例#9
0
文件: chans.go 项目: rjammala/emgo
func (c *chanS) unlock() {
	barrier.Memory()
	atomic.CompareAndSwapInt32(&c.state, 1, 0)
	c.event.Send()
}
示例#10
0
文件: chans.go 项目: rjammala/emgo
// 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()
}