VB.NET并行与分布式编程(4)-线程栈[2]

三、栈内存

1、每个WINDOWS都有一个栈基址和栈限址,二者合在一起表示栈的有效内存范围。栈限址不是固定的,程序需要更多内存空间里,栈限址没有超过保留的栈内存范围,则可以要求更多的内存页

2、在栈限址外是栈的守护页,当访问到守护页时,会引发STATUS_GUARD_PAGE_VIOLATION异常,当异常发生后,操作系统捕捉后,提交下一页内存,然后将其做为新的守护页,这相当于分配了一个新的页给程序访问,就是栈动态增长。
具体机制是当访问了带PAGE_GUARD 属性的内存时,操作系统意识到当前栈内存已经用完,因为栈内存的下一页就是守护页,操作系统马上清除守护页的PAGE_GUARD 标志,将其用于补充当前的栈内存,同时申请一个新的内存页做为守护页,随着新守护页的不断申请,越来越多的老守护页加入当前栈空间,这就是动态增长

3、从MSDN中可以查到
A guard page provides a one-shot alarm for memory page access. This can be useful for an application that needs to monitor the growth of large dynamic data structures. For example, there are operating systems that use guard pages to implement automatic stack checking.

To create a guard page, set the PAGE_GUARD page protection modifier for the page. This value can be specified, along with other page protection modifiers, in the VirtualAlloc, VirtualAllocEx, VirtualProtect, and VirtualProtectEx functions. The PAGE_GUARD modifier can be used with any other page protection modifiers, except PAGE_NOACCESS.

If a program attempts to access an address within a guard page, the system raises a STATUS_GUARD_PAGE_VIOLATION (0x80000001) exception. The system also clears the PAGE_GUARD modifier, removing the memory page's guard page status. The system will not stop the next attempt to access the memory page with a STATUS_GUARD_PAGE_VIOLATION exception.

If a guard page exception occurs during a system service, the service fails and typically returns some failure status indicator. Since the system also removes the relevant memory page's guard page status, the next invocation of the same system service won't fail due to a STATUS_GUARD_PAGE_VIOLATION exception (unless, of course, someone reestablishes the guard page).

The following short program illustrates the behavior of guard page protection.

保护页提供了一个内存页的访问警告,对应用程序监视,操作系统用它来实现栈的自动检查
在 VirtualAlloc, VirtualAllocEx, VirtualProtect, and VirtualProtectEx 函数中可以定义这个参数
目前我们使用VB.NET进行多线程编程,使用的是.NET的CLR托管线程,CLR使用了SetThreadStackGuarantee来以更大的增量来递增栈限址,这个API指定了守护区域大小,如果将大小设置为0,则返回当前的守护区域大小。
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
很抱歉,由于引用[1]中提供的是vue-quill-editor.js的使用教程,而非与vb.net的集成方法,因此无法直接回答该问题。但是,我可以提供一些相关信息来帮助你更好地了解如何在vb.net中使用vue-quill-editor。 Vue-quill-editor是一个基于Quill.js的富文本编辑器,而Quill.js本身是一个纯JavaScript库,因此可以在任何支持JavaScript的环境中使用。在vb.net中使用Vue-quill-editor,你需要将其作为一个JavaScript库引入到你的项目中,并在你的代码中调用它的API来实现富文本编辑器的功能。 具体来说,你需要在你的vb.net项目中引入Vue.js和Vue-quill-editor.js这两个JavaScript库,并在你的代码中创建一个Vue实例来初始化Vue-quill-editor组件。以下是一个简单的示例代码: ```html <!-- 引入Vue.js和Vue-quill-editor.js --> <script src="https://cdn.jsdelivr.net/npm/vue"></script> <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue-quill-editor.js"></script> <!-- 在HTML中添加一个容器元素,用于渲染Vue-quill-editor组件 --> <div id="editor"> <quill-editor></quill-editor> </div> <!-- 在JavaScript中创建Vue实例,并初始化Vue-quill-editor组件 --> <script> new Vue({ el: '#editor', components: { 'quill-editor': VueQuillEditor.default } }) </script> ``` 在上面的代码中,我们首先在HTML中添加了一个id为“editor”的容器元素,用于渲染Vue-quill-editor组件。然后,在JavaScript中创建了一个Vue实例,并将其绑定到“editor”元素上。最后,我们通过调用Vue-quill-editor组件的API来初始化富文本编辑器。 需要注意的是,上面的代码仅仅是一个简单的示例,实际使用中还需要根据具体的需求进行相应的配置和调整。同时,由于Vue-quill-editor是一个第三方库,其API和使用方法可能会随着版本的更新而发生变化,因此在使用时需要仔细查阅官方文档并进行相应的调整。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值