Example #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)
}
Example #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)
}
func adviseRead(mem []byte) {
	syscall.Madvise(mem, syscall.MADV_SEQUENTIAL|syscall.MADV_WILLNEED)
}
func adviseWrite(mem []byte) {
	syscall.Madvise(mem, syscall.MADV_SEQUENTIAL)
}
Example #5
0
// Give kernel hints about usage pattern.
func (m Mmap) Advise(advice Advice) error {
	return syscall.Madvise(m, int(advice))
}