30.10.2014 Views

o_195h4n6al16jb186b1b2qs7fgssa.pdf

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

the calling process's data segment. The change is made by resetting<br />

the process's break value and allocating the appropriate amount of<br />

space. The break value is the address of the first location beyond the<br />

end of the data segment. The amount of allocated space increases as<br />

the break value increases.<br />

Newly allocated space is uninitialized.<br />

This helper function is used by the Standard C Library function<br />

malloc().<br />

dsPIC<br />

®<br />

Language Tools Libraries<br />

DS51456B-page 368<br />

2004 Microchip Technology Inc.<br />

Default Behavior: If the argument enddsis zero, the function sets the global<br />

variable<br />

__curbrkto the address of the start of the heap, and returns zero.<br />

If the argument enddsis non-zero, and has a value less than the<br />

address of the end of the heap, the function sets the global variable<br />

__curbrkto the value of enddsand returns zero.<br />

Otherwise, the global variable __curbrkis unchanged, and the<br />

function returns -1.<br />

The argument enddsmust be within the heap range (see data space<br />

memory map below.)<br />

Notice that, since the stack is located immediately above the heap,<br />

using brk()or sbrk()has little effect on the size of the dynamic<br />

memory pool. The brk()and sbrk()functions are primarily intended<br />

for use in run-time environments where the stack grows downward and<br />

the heap grows upward.<br />

The linker allocates a block ofmemory for the heap if the<br />

-Wl,--heap=noption is specified, where nis the desired heap size in<br />

characters. The starting and ending addresses of the heap are reported<br />

in variables _heapand _eheap, respectively.<br />

For MPLAB C30, using the linker's heap size option is the standard way<br />

of controlling heap size, rather than relying on brk()and sbrk().<br />

File: brk.c<br />

close<br />

Description: Close a file.<br />

Include: None<br />

Prototype: int close(int handle);<br />

Argument: handle handle referring to an opened file<br />

hệ thống tập tin.<br />

File: rename.c<br />

dsPIC<br />

®<br />

Thư viện Công cụ Ngôn ngữ<br />

DS51456B trang 372<br />

sbrk<br />

2004 Microchip Technology Inc<br />

Mô tả: Mở rộng không gian dữ liệu của quá trình một tăng nhất định.<br />

Bao gồm: Không<br />

Nguyên mẫu: void * sbrk (int incr);<br />

Đối số: số incr của các nhân vật để tăng / giảm<br />

Quay trở lại giá trị gia tăng: Quay trở lại sự bắt đầu của không gian mới phân<br />

bổ, hoặc '-1' lỗi.<br />

Bình luận: sbrk () cho biết thêm incrcharacters với giá trị phá vỡ và thay đổi<br />

phân bổ không gian cho phù hợp. incrcan được tiêu cực, trong trường hợp đó<br />

số lượng không gian được phân bổ được giảm.<br />

sbrk () được sử dụng để tự động thay đổi số lượng của không gian phân bổ<br />

cho phân đoạn dữ liệu của quá trình gọi. Sự thay đổi này được thực hiện bởi<br />

đặt lại giá trị đột phá của quá trình và phân bổ thích hợp<br />

số lượng không gian. Giá trị nghỉ là địa chỉ của địa điểm đầu tiên<br />

vượt ra ngoài kết thúc của đoạn dữ liệu. Số lượng không gian được phân bổ<br />

tăng như tăng giá trị nghỉ.<br />

Đây là một chức năng trợ giúp gọi bythe Thư viện chuẩn C chức năng<br />

malloc ().<br />

Hành vi mặc định: Nếu biến toàn cầu __curbrkis không, chức năng gọi brk () để<br />

khởi tạo giá trị nghỉ. Nếu brk () trả về -1, do đó, hiện chức năng này.<br />

Nếu incris không, giá trị hiện tại của __curbrkis biến toàn cầu<br />

trả lại.<br />

Nếu incris không, chức năng kiểm tra rằng địa chỉ<br />

(__curbrk + Incr) ít hơn so với địa chỉ cuối cùng của đống. Nếu đó là<br />

ít hơn, các biến toàn cầu __curbrkis cập nhật giá trị đó, và<br />

chức năng trả về giá trị unsigned của __curbrk.<br />

Nếu không, chức năng trả về -1.<br />

Xem mô tả các brk ().<br />

File: sbrk.c<br />

hệ thống<br />

Mô tả: Thực hiện một lệnh.<br />

Bao gồm:<br />

Nguyên mẫu: int hệ thống (const char * s);<br />

Đối số: s lệnh được thực thi.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!