Exemplo n.º 1
0
func (b *Buffer) dontNeed(i, j uint64) error {
	// Since i is rounded up to the nearest multiple of
	// pageSize before the call, i > j is not an error.
	if i > j {
		return nil
	}
	return syscall.Madvise(b.data[i:j], syscall.MADV_DONTNEED)
}
Exemplo n.º 2
0
func (buf *sharedBuffer) Advise(offset, length, advice int) error {
	b := buf.Bytes()
	err := checkOffsetLength(b, offset, length)
	if err == nil {
		err = syscall.Madvise(b[offset:offset+length], advice)
	}
	return os.NewSyscallError("shm: madvise", err)
}
Exemplo n.º 3
0
func adviseRead(mem []byte) {
	syscall.Madvise(mem, syscall.MADV_SEQUENTIAL|syscall.MADV_WILLNEED)
}
Exemplo n.º 4
0
func adviseWrite(mem []byte) {
	syscall.Madvise(mem, syscall.MADV_SEQUENTIAL)
}
Exemplo n.º 5
0
// Give kernel hints about usage pattern.
func (m Mmap) Advise(advice Advice) error {
	return syscall.Madvise(m, int(advice))
}