Movatterモバイル変換


[0]ホーム

URL:


Skip Navigation Links
Exit Print View
Link to oracle.comman pages section 2: System Calls    Oracle Solaris 11 Information Library
Oracle Technology Network
Library
PDF
Print View
Feedback
search filter icon
search icon
 Search Scope:

Document Information

Preface

Introduction

System Calls

access(2)

acct(2)

acl(2)

adjtime(2)

alarm(2)

brk(2)

chdir(2)

chmod(2)

chown(2)

chroot(2)

close(2)

creat(2)

dup(2)

exec(2)

execl(2)

execle(2)

execlp(2)

execv(2)

execve(2)

execvex(2)

execvp(2)

_Exit(2)

_exit(2)

exit(2)

faccessat(2)

facl(2)

fchdir(2)

fchmod(2)

fchmodat(2)

fchown(2)

fchownat(2)

fchroot(2)

fcntl(2)

fexecve(2)

fgetlabel(2)

fork1(2)

fork(2)

forkall(2)

forkallx(2)

forkx(2)

fpathconf(2)

fstat(2)

fstatat(2)

fstatvfs(2)

futimens(2)

futimesat(2)

getacct(2)

getcontext(2)

getdents(2)

getegid(2)

geteuid(2)

getgid(2)

getgroups(2)

getisax(2)

getitimer(2)

getlabel(2)

getmsg(2)

getpflags(2)

getpgid(2)

getpgrp(2)

getpid(2)

getpmsg(2)

getppid(2)

getppriv(2)

getprojid(2)

getrctl(2)

getrlimit(2)

getsid(2)

gettaskid(2)

getuid(2)

getustack(2)

ioctl(2)

issetugid(2)

kill(2)

lchown(2)

link(2)

linkat(2)

llseek(2)

lseek(2)

lstat(2)

_lwp_cond_broadcast(2)

_lwp_cond_reltimedwait(2)

_lwp_cond_signal(2)

_lwp_cond_timedwait(2)

_lwp_cond_wait(2)

_lwp_continue(2)

_lwp_info(2)

_lwp_kill(2)

_lwp_mutex_lock(2)

_lwp_mutex_trylock(2)

_lwp_mutex_unlock(2)

_lwp_self(2)

_lwp_sema_init(2)

_lwp_sema_post(2)

_lwp_sema_trywait(2)

_lwp_sema_wait(2)

_lwp_suspend(2)

memcntl(2)

meminfo(2)

mincore(2)

mkdir(2)

mkdirat(2)

mknod(2)

mknodat(2)

mmap(2)

mmapobj(2)

mount(2)

mprotect(2)

msgctl(2)

msgget(2)

msgids(2)

msgrcv(2)

msgsnap(2)

msgsnd(2)

munmap(2)

nice(2)

ntp_adjtime(2)

ntp_gettime(2)

open(2)

openat(2)

pathconf(2)

pause(2)

pcsample(2)

pipe(2)

poll(2)

p_online(2)

ppoll(2)

pread(2)

priocntl(2)

priocntlset(2)

processor_bind(2)

processor_info(2)

profil(2)

pset_assign(2)

pset_bind(2)

pset_create(2)

pset_destroy(2)

pset_getattr(2)

pset_info(2)

pset_list(2)

pset_setattr(2)

putacct(2)

putmsg(2)

putpmsg(2)

pwrite(2)

read(2)

readlink(2)

readlinkat(2)

readv(2)

rename(2)

renameat(2)

resolvepath(2)

rmdir(2)

sbrk(2)

semctl(2)

semget(2)

semids(2)

semop(2)

semtimedop(2)

setcontext(2)

setegid(2)

seteuid(2)

setgid(2)

setgroups(2)

setitimer(2)

setpflags(2)

setpgid(2)

setpgrp(2)

setppriv(2)

setrctl(2)

setregid(2)

setreuid(2)

setrlimit(2)

setsid(2)

settaskid(2)

setuid(2)

setustack(2)

shmadv(2)

shmat(2)

shmctl(2)

shmdt(2)

shmget(2)

shmids(2)

shmop(2)

sigaction(2)

sigaltstack(2)

sigpending(2)

sigprocmask(2)

sigsend(2)

sigsendset(2)

sigsuspend(2)

sigwait(2)

__sparc_utrap_install(2)

stat(2)

statvfs(2)

stime(2)

swapctl(2)

symlink(2)

symlinkat(2)

sync(2)

sysfs(2)

sysinfo(2)

time(2)

times(2)

uadmin(2)

ulimit(2)

umask(2)

umount(2)

umount2(2)

uname(2)

unlink(2)

unlinkat(2)

ustat(2)

utime(2)

utimensat(2)

utimes(2)

uucopy(2)

vfork(2)

vforkx(2)

vhangup(2)

waitid(2)

wracct(2)

write(2)

writev(2)

yield(2)

memcntl

- memory management control

Synopsis

#include <sys/types.h>#include <sys/mman.h>intmemcntl(caddr_taddr,size_tlen,intcmd,caddr_targ,intattr,intmask);

Description

Thememcntl() function allows the calling process to apply a variety ofcontrol operations over the address space identified by the mappings established forthe address range [addr,addr +len).

Theaddr argument must be a multiple of the pagesize as returnedbysysconf(3C). The scope of the control operations can be further defined withadditional selection criteria (in the form of attributes) according to the bitpattern contained inattr.

The following attributes specify page mapping selection criteria:

SHARED

Page is mapped shared.

PRIVATE

Page is mapped private.

The following attributes specify page protection selection criteria. The selection criteria areconstructed by a bitwise OR operation on the attribute bits and mustmatch exactly.

PROT_READ

Page can be read.

PROT_WRITE

Page can be written.

PROT_EXEC

Page can be executed.

The following criteria may also be specified:

PROC_TEXT

Process text.

PROC_DATA

Process data.

ThePROC_TEXT attribute specifies all privately mapped segments with read and executepermission, and thePROC_DATA attribute specifies all privately mapped segments with writepermission.

Selection criteria can be used to describe various abstract memory objects withinthe address space on which to operate. If an operation shall notbe constrained by the selection criteria,attr must have the value0.

The operation to be performed is identified by the argumentcmd. Thesymbolic names for the operations are defined in <sys/mman.h> as follows:

MC_LOCK

Lock in memory all pages in the range with attributesattr. A given page may be locked multiple times through different mappings; however, within a given mapping, page locks do not nest. Multiple lock operations on the same address in the same process will all be removed with a single unlock operation. A page locked in one process and mapped in another (or visible through a different mapping in the locking process) is locked in memory as long as the locking process does neither an implicit nor explicit unlock operation. If a locked mapping is removed, or a page is deleted through file removal or truncation, an unlock operation is implicitly performed. If a writableMAP_PRIVATE page in the address range is changed, the lock will be transferred to the private page.

Thearg argument is not used, but must be 0 to ensure compatibility with potential future enhancements.

MC_LOCKAS

Lock in memory all pages mapped by the address space with attributesattr. Theaddr andlen arguments are not used, but must beNULL and0 respectively, to ensure compatibility with potential future enhancements. Thearg argument is a bit pattern built from the flags:

MCL_CURRENT

Lock current mappings.

MCL_FUTURE

Lock future mappings.

The value ofarg determines whether the pages to be locked are those currently mapped by the address space, those that will be mapped in the future, or both. IfMCL_FUTURE is specified, then all mappings subsequently added to the address space will be locked, provided sufficient memory is available.

MC_SYNC

Write to their backing storage locations all modified pages in the range with attributesattr. Optionally, invalidate cache copies. The backing storage for a modifiedMAP_SHARED mapping is the file the page is mapped to; the backing storage for a modifiedMAP_PRIVATE mapping is its swap area. Thearg argument is a bit pattern built from the flags used to control the behavior of the operation:

MS_ASYNC

Perform asynchronous writes.

MS_SYNC

Perform synchronous writes.

MS_INVALIDATE

Invalidate mappings.

MS_ASYNC Return immediately once all write operations are scheduled; withMS_SYNC the function will not return until all write operations are completed.

MS_INVALIDATE Invalidate all cached copies of data in memory, so that further references to the pages will be obtained by the system from their backing storage locations. This operation should be used by applications that require a memory object to be in a known state.

MC_UNLOCK

Unlock all pages in the range with attributesattr. Thearg argument is not used, but must be0 to ensure compatibility with potential future enhancements.

MC_UNLOCKAS

Remove address space memory locks and locks on all pages in the address space with attributesattr. Theaddr,len, andarg arguments are not used, but must beNULL, 0 and 0, respectively, to ensure compatibility with potential future enhancements.

MC_HAT_ADVISE

Advise system how a region of user-mapped memory will be accessed. Thearg argument is interpreted as a “struct memcntl_mha *”. The following members are defined in astruct memcntl_mha:

uint_t mha_cmd;uint_t mha_flags;size_t mha_pagesize;

The accepted values formha_cmd are:

MHA_MAPSIZE_VAMHA_MAPSIZE_STACKMHA_MAPSIZE_BSSBRK

Themha_flags member is reserved for future use and must always be set to 0. Themha_pagesize member must be a valid size as obtained fromgetpagesizes(3C) or the constant value 0 to allow the system to choose an appropriate hardware address translation mapping size.

MHA_MAPSIZE_VA sets the preferred hardware address translation mapping size of the region of memory fromaddr toaddr +len. Bothaddr andlen must be aligned to anmha_pagesize boundary. The entire virtual address region fromaddr toaddr +len must not have any holes. Permissions within eachmha_pagesize–aligned portion of the region must be consistent. When a size of 0 is specified, the system selects an appropriate size based on the size and alignment of the memory region, type of processor, and other considerations.

MHA_MAPSIZE_STACK sets the preferred hardware address translation mapping size of the process main thread stack segment. Theaddr andlen arguments must beNULL and 0, respectively.

MHA_MAPSIZE_BSSBRK sets the preferred hardware address translation mapping size of the process heap. Theaddr andlen arguments must beNULL and 0, respectively. See the NOTES section of theppgsz(1) manual page for additional information on process heap alignment.

Theattr argument must be 0 for allMC_HAT_ADVISE operations.

Themask argument must be0; it is reserved for future use.

Locks established with the lock operations are not inherited by a childprocess afterfork(2). Thememcntl() function fails if it attempts to lock morememory than a system-specific limit.

Due to the potential impact on system resources, the operationsMC_LOCKAS,MC_LOCK,MC_UNLOCKAS, andMC_UNLOCK are restricted to privileged processes.

Usage

Thememcntl() function subsumes the operations ofplock(3C).

MC_HAT_ADVISE is intended to improve performance of applications that use large amountsof memory on processors that support multiple hardware address translation mapping sizes;however, it should be used with care. Not all processors support allsizes with equal efficiency. Use of larger sizes may also introduce extra overheadthat could reduce performance or available memory. Using large sizes forone application may reduce available resources for other applications and result inslower system wide performance.

Return Values

Upon successful completion,memcntl() returns0; otherwise, it returns-1 and setserrno to indicate an error.

Errors

Thememcntl() function will fail if:

EAGAIN

When the selection criteria match, some or all of the memory identified by the operation could not be locked whenMC_LOCK orMC_LOCKAS was specified, some or all mappings in the address range [addr,addr +len) are locked for I/O whenMC_HAT_ADVISE was specified, or the system has insufficient resources whenMC_HAT_ADVISE was specified.

Thecmd isMC_LOCK orMC_LOCKAS and locking the memory identified by this operation would exceed a limit or resource control on locked memory.

EBUSY

When the selection criteria match, some or all of the addresses in the range [addr, addr + len) are locked andMC_SYNC with theMS_INVALIDATE option was specified.

EINVAL

Theaddr argument specifies invalid selection criteria or is not a multiple of the page size as returned bysysconf(3C).

Theaddr and/orlen argument does not have the value0 whenMC_LOCKAS orMC_UNLOCKAS is specified.

Thearg argument is not valid for the function specified.

Themha_pagesize ormha_cmd member is invalid.

MC_HAT_ADVISE is specified and not all pages in the specified region have the same access permissions within the given size boundaries.

MC_HAT_ADVISE is specified for a region of shared memory attached with theSHM_SHARE_MMU orSHM_PAGEABLE attribute (seeshmop(2)).

ENOMEM

When the selection criteria match, some or all of the addresses in the range [addr,addr +len) are invalid for the address space of a process or specify one or more pages which are not mapped.

EPERM

The {PRIV_PROC_LOCK_MEMORY} privilege is not asserted in the effective set of the calling process andMC_LOCK,MC_LOCKAS,MC_UNLOCK, orMC_UNLOCKAS was specified.

Attributes

Seeattributes(5) for descriptions of the following attributes:

ATTRIBUTE TYPE
ATTRIBUTE VALUE
MT-Level
MT-Safe

See Also

ppgsz(1),fork(2),mmap(2),mprotect(2),getpagesizes(3C),mlock(3C),mlockall(3C),msync(3C),plock(3C),sysconf(3C),attributes(5),privileges(5)

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.Legal Notices
PreviousNext

[8]ページ先頭

©2009-2025 Movatter.jp