关于brk和sbrk [英] Regarding brk and sbrk

查看:121
本文介绍了关于brk和sbrk的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨伙计,


能帮助理解brk和sbrk。这些是如何实现的(这意味着如何分配记忆)。 malloc将如何将这些brk和sbrk称为b
。还请给出任何C程序示例,其中

brk和sbrk用于分配内存。


感谢你在这方面的帮助,

谢谢,

Vikas。

Hi folks,

Can some help in understanding brk and sbrk. how does these are
implemeted(means how the memeory will be allocated). How malloc will
call these brk and sbrk. Please also give any example C program, where
brk and sbrk are used to allocate memory.

Appreciate your help in this regard,
Thanks,
Vikas.

推荐答案

10月17日下午1点24分,venkat < venkatavi ... @ gmail.comwrote:
On Oct 17, 1:24 pm, venkat <venkatavi...@gmail.comwrote:

可以帮助理解brk和sbrk。这些是如何实现的(这意味着如何分配记忆)。 malloc将如何将这些brk和sbrk称为b
。还请提供任何示例C程序,其中

brk和sbrk用于分配内存。
Can some help in understanding brk and sbrk. how does these are
implemeted(means how the memeory will be allocated). How malloc will
call these brk and sbrk. Please also give any example C program, where
brk and sbrk are used to allocate memory.



brk()和sbrk()未在C标准中定义,并且故意

排除

除外来自POSIX.1标准(见第B.1.1.1.3和B段。

8.3.3)。

brk() and sbrk() are not defined in the C Standard and are
deliberately
excluded from the POSIX.1 standard (see paragraphs B.1.1.1.3 and B.
8.3.3).




" venkat" < ve ********** @ gmail.comwrote in message

news:11 ******************** **@v23g2000prn.googlegr oups.com ...

"venkat" <ve**********@gmail.comwrote in message
news:11**********************@v23g2000prn.googlegr oups.com...

嗨大家好,


可以帮助理解brk和SBRK。这些是如何实现的(这意味着如何分配记忆)。 malloc将如何将这些brk和sbrk称为b
。还请提供任何示例C程序,其中

brk和sbrk用于分配内存。
Hi folks,

Can some help in understanding brk and sbrk. how does these are
implemeted(means how the memeory will be allocated). How malloc will
call these brk and sbrk. Please also give any example C program, where
brk and sbrk are used to allocate memory.



如上所述,这些都不是标准的。

在此之后,它们甚至不是一个好主意...


现在,一般信息:

malloc实施趋势从操作系统中获取大块内存,并且brk

和sbrk是一种这样的方法(他们通过滑动指针来工作,并且

通常根据需要在页面中进行映射等等on)。


另一种,一般更好的方法,就是使用mmap(在linux上和

的朋友)。

Windows上的
,获取原始内存的一般方法是通过VirtualAlloc。


然而,这一切都是一个非常便携的问题,所以,确切的
答案在很大程度上取决于目标操作系统...


或者其他......

as noted, these are not standard.
following this, they are not even a good idea...

now, for general info:
malloc implementations tend to grab chunks of memory from the OS, and brk
and sbrk were one such method (they worked by sliding a pointer, and
generally mapping in pages as needed and so on).

another, generally better, method, is the use of mmap (on linux and
friends).

on windows, a general way to grab raw memory is through VirtualAlloc.

however, all this is a generally non-portable issue, and so, the exact
answers will depend highly on the target OS...

or such...


感谢你在这方面的帮助,


谢谢,

Vikas。
Appreciate your help in this regard,
Thanks,
Vikas.



10月17日凌晨3:24,venkat< venkatavi ... @ gmail.comwrote:
On Oct 17, 3:24 am, venkat <venkatavi...@gmail.comwrote:

嗨伙计们,


可以帮助理解brk和sbrk。这些是如何实现的(这意味着如何分配记忆)。 malloc将如何将这些brk和sbrk称为b
。还请提供任何示例C程序,其中

brk和sbrk用于分配内存。
Hi folks,

Can some help in understanding brk and sbrk. how does these are
implemeted(means how the memeory will be allocated). How malloc will
call these brk and sbrk. Please also give any example C program, where
brk and sbrk are used to allocate memory.



试试新闻:comp.unix.programmer,他们会立即告诉

你不要使用这些功能。

Try over on news:comp.unix.programmer, where they will promptly tell
you not to use those functions.


这篇关于关于brk和sbrk的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆