Add support for pthread_attr_get/setguardsize()

* Added the aforementioned functions.
* create_area_etc() now takes a guard size parameter.
* The thread_info::stack_base/end range now refers to the usable range
  only.
This commit is contained in:
Hamish Morrison
2012-12-28 18:02:58 +00:00
parent 00e7904406
commit d1f280c805
29 changed files with 148 additions and 87 deletions
+4 -5
View File
@@ -185,6 +185,10 @@ extern int pthread_attr_getschedparam(const pthread_attr_t *attr,
extern int pthread_attr_setschedparam(pthread_attr_t *attr,
const struct sched_param *param);
extern int pthread_attr_getguardsize(const pthread_attr_t *attr,
size_t *guardsize);
extern int pthread_attr_setguardsize(pthread_attr_t *attr, size_t guardsize);
#if 0 /* Unimplemented attribute functions: */
/* [TPS] */
@@ -196,11 +200,6 @@ extern int pthread_attr_getschedpolicy(const pthread_attr_t *attr,
int *policy);
extern int pthread_attr_setschedpolicy(pthread_attr_t *attr, int policy);
/* [XSI] */
extern int pthread_attr_getguardsize(const pthread_attr_t *attr,
size_t *guardsize);
extern int pthread_attr_setguardsize(pthread_attr_t *attr, size_t guardsize);
/* [TSA] */
extern int pthread_attr_getstackaddr(const pthread_attr_t *attr,
void **stackaddr);
+2
View File
@@ -117,6 +117,8 @@ public:
inline void IncrementWiredPagesCount();
inline void DecrementWiredPagesCount();
virtual int32 GuardSize() { return 0; }
void AddConsumer(VMCache* consumer);
status_t InsertAreaLocked(VMArea* area);
+2 -2
View File
@@ -77,7 +77,7 @@ void forbid_page_faults(void);
// private kernel only extension (should be moved somewhere else):
area_id create_area_etc(team_id team, const char *name, uint32 size,
uint32 lock, uint32 protection, uint32 flags,
uint32 lock, uint32 protection, uint32 flags, uint32 guardSize,
const virtual_address_restrictions* virtualAddressRestrictions,
const physical_address_restrictions* physicalAddressRestrictions,
void **_address);
@@ -95,7 +95,7 @@ status_t vm_unreserve_address_range(team_id team, void *address, addr_t size);
status_t vm_reserve_address_range(team_id team, void **_address,
uint32 addressSpec, addr_t size, uint32 flags);
area_id vm_create_anonymous_area(team_id team, const char* name, addr_t size,
uint32 wiring, uint32 protection, uint32 flags,
uint32 wiring, uint32 protection, uint32 flags, addr_t guardSize,
const virtual_address_restrictions* virtualAddressRestrictions,
const physical_address_restrictions* physicalAddressRestrictions,
bool kernel, void** _address);
@@ -40,6 +40,7 @@ typedef struct _pthread_attr {
int32 detach_state;
int32 sched_priority;
size_t stack_size;
size_t guard_size;
} pthread_attr;
typedef struct _pthread_rwlockattr {
+6 -8
View File
@@ -12,14 +12,11 @@
/** Size of the stack given to teams in user space */
#define USER_STACK_GUARD_PAGES 4 // 16 kB
#define USER_MAIN_THREAD_STACK_SIZE (16 * 1024 * 1024 \
- USER_STACK_GUARD_PAGES * B_PAGE_SIZE) // 16 MB
#define USER_STACK_SIZE (256 * 1024 \
- USER_STACK_GUARD_PAGES * B_PAGE_SIZE) // 256 kB
#define MIN_USER_STACK_SIZE (4 * 1024) // 4 KB
#define MAX_USER_STACK_SIZE (16 * 1024 * 1024 \
- USER_STACK_GUARD_PAGES * B_PAGE_SIZE) // 16 MB
#define USER_STACK_GUARD_SIZE (4 * B_PAGE_SIZE) // 16 kB
#define USER_MAIN_THREAD_STACK_SIZE (16 * 1024 * 1024) // 16 MB
#define USER_STACK_SIZE (256 * 1024) // 256 kB
#define MIN_USER_STACK_SIZE (4 * 1024) // 4 KB
#define MAX_USER_STACK_SIZE (16 * 1024 * 1024) // 16 MB
// The type of object a thread blocks on (thread::wait::type, set by
@@ -50,6 +47,7 @@ struct thread_creation_attributes {
void* args2;
void* stack_address;
size_t stack_size;
size_t guard_size;
pthread_t pthread;
uint32 flags;
};