Sponsored Content
Top Forums Programming pthread_create fails when used with pthread_attr_setinheritsched() on HPUX Post 302102644 by jeet_xp on Thursday 11th of January 2007 11:32:44 PM
Old 01-12-2007
pthread_create fails when used with pthread_attr_setinheritsched() on HPUX

I am using HPUX on Itanium and I have c program where I am doing something like this
but this pthread_create always fails at runtime
prio = PRI_MAX;
prio_low = PRI_MIN;
.
.
.
.
struct sched_param sched_param={1};
sched_param.sched_priority=prio;
thret = pthread_attr_setschedparam(&serv_attr, &sched_param);

thret = pthread_attr_setinheritsched(&serv_attr,PTHREAD_EXPLICIT_SCHED);

.
.
.
thret = pthread_create(&sthread,&serv_attr,server_main, 0);

but if i remove this line

thret = pthread_attr_setinheritsched(&serv_attr,PTHREAD_EXPLICIT_SCHED);

it works fine, can anyone suggest whats happening here. I have tried the same on AIX and Solaris, it works there.
 

10 More Discussions You Might Find Interesting

1. Programming

pthread_create problem

Here is simple code for multithreading in POSIX: void* simplethread(void* arg) { printf("Hello World\n"); } int main(void) { pthread_t id; pthread_create(&id, NULL, simplethread, NULL); return 0; } Whether the new thread will run or not depends on the OS. Tricky ... (5 Replies)
Discussion started by: _rocky
5 Replies

2. Programming

unresolve pthread_create etc

how to do with that? after cc -o xxxx xxxx.c ld: Unresolved: _pthread_create _pthread_deteach _pthread_exit Thanks (3 Replies)
Discussion started by: zhshqzyc
3 Replies

3. Programming

pthread_create and scope usage

I have a problem with a C multi-threaded program I am writing. I cannot figure out how to keep the unique key value at the thread level. I wrote a program in C that forked a bunch of processes and then decided to convert it to threads and I can't keep the key unique to each thread. In a nutshell... (3 Replies)
Discussion started by: jenmead
3 Replies

4. Programming

Pthread_create issue

Hello My problem goes like this: I have used Pthread_create, and I have tryed to create 2 proccess but nothing happens! It does not even matter what the function im trying to create do. It is if im trying to activate an empty function. This is my code. Any help will be highly appreciated.... (1 Reply)
Discussion started by: Hellboy
1 Replies

5. Shell Programming and Scripting

Need Script to Use CPUs on a HPUX server to simulate Workload Manager on HPUX.

I am running HPUX and using WLM (workload manager). I want to write a script to fork CPUs to basically take CPUs from other servers to show that the communication is working and CPU licensing is working. Basically, I want to build a script that will use up CPU on a server. Any ideas? (2 Replies)
Discussion started by: cpolikowsky
2 Replies

6. Programming

How Can I use pthread_create ?

Hi. I use C++ and I wishes to create a thread with the pthread_create function, my question is, how can I do this if I wish that the function will be a member of the class ?? I know from windows programming that I can declare a static function like this static unsigned int __stdcall... (7 Replies)
Discussion started by: shvalb
7 Replies

7. Programming

pthread_create

The prototype for pthread_create function is like this:- int pthread_create(pthread_t *thread,pthread_attr_t *attr,void *(*start routine),void *arg); Q.1 .Why the return type of the start_routine must be void*?? Q.2. Why should we pass arg by converting into void * only ?? Thank You (3 Replies)
Discussion started by: sunil_abhay
3 Replies

8. UNIX for Dummies Questions & Answers

Pthread_create problem

Hi, I'm trying to do my homework assignment but I am having trouble using the pthread_create fucntion. Here is my code________________ //Alicia Johnson //sum_pid program //creates n number of threads. These threads create a random number //then adds the number to a global array. Then... (1 Reply)
Discussion started by: ajohns38
1 Replies

9. HP-UX

pwage-hpux-T for Trusted HPUX servers

I'm sharing this in case anybody needs it. Modified from the original solaris pwage script. This modified hpux script will check /etc/password file on hpux trusted systems search /tcb and grep the required u_succhg field. Calculate days to expiry and notify users via email. original solaris... (2 Replies)
Discussion started by: sparcguy
2 Replies

10. Programming

fork vs pthread_create

Suppose I have a simple program main() with a global varibale int x=0. int x = 0; main() { print("%d\n",x); } I want to create two threads/process which must access this variable x in sync. Which one will be better threads( pthread_create ) or process( fork )? If I go with fork() then... (1 Reply)
Discussion started by: rupeshkp728
1 Replies
PTHREAD_ATTR_SETSCHEDPARAM(3)				     Linux Programmer's Manual				     PTHREAD_ATTR_SETSCHEDPARAM(3)

NAME
pthread_attr_setschedparam, pthread_attr_getschedparam - set/get scheduling parameter attributes in thread attributes object SYNOPSIS
#include <pthread.h> int pthread_attr_setschedparam(pthread_attr_t *attr, const struct sched_param *param); int pthread_attr_getschedparam(const pthread_attr_t *attr, struct sched_param *param); Compile and link with -pthread. DESCRIPTION
The pthread_attr_setschedparam() function sets the scheduling parameter attributes of the thread attributes object referred to by attr to the values specified in the buffer pointed to by param. These attributes determine the scheduling parameters of a thread created using the thread attributes object attr. The pthread_attr_getschedparam() returns the scheduling parameter attributes of the thread attributes object attr in the buffer pointed to by param. Scheduling parameters are maintained in the following structure: struct sched_param { int sched_priority; /* Scheduling priority */ }; As can be seen, only one scheduling parameter is supported. For details of the permitted ranges for scheduling priorities in each schedul- ing policy, see sched(7). In order for the parameter setting made by pthread_attr_setschedparam() to have effect when calling pthread_create(3), the caller must use pthread_attr_setinheritsched(3) to set the inherit-scheduler attribute of the attributes object attr to PTHREAD_EXPLICIT_SCHED. RETURN VALUE
On success, these functions return 0; on error, they return a nonzero error number. ERRORS
pthread_attr_setschedparam() can fail with the following error: EINVAL The priority specified in param does not make sense for the current scheduling policy of attr. POSIX.1 also documents an ENOTSUP error for pthread_attr_setschedparam(). This value is never returned on Linux (but portable and future- proof applications should nevertheless handle this error return value). ATTRIBUTES
For an explanation of the terms used in this section, see attributes(7). +------------------------------+---------------+---------+ |Interface | Attribute | Value | +------------------------------+---------------+---------+ |pthread_attr_setschedparam(), | Thread safety | MT-Safe | |pthread_attr_getschedparam() | | | +------------------------------+---------------+---------+ CONFORMING TO
POSIX.1-2001, POSIX.1-2008. NOTES
See pthread_attr_setschedpolicy(3) for a list of the thread scheduling policies supported on Linux. EXAMPLE
See pthread_setschedparam(3). SEE ALSO
sched_get_priority_min(2), pthread_attr_init(3), pthread_attr_setinheritsched(3), pthread_attr_setschedpolicy(3), pthread_create(3), pthread_setschedparam(3), pthread_setschedprio(3), pthreads(7), sched(7) COLOPHON
This page is part of release 4.15 of the Linux man-pages project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at https://www.kernel.org/doc/man-pages/. Linux 2017-09-15 PTHREAD_ATTR_SETSCHEDPARAM(3)
All times are GMT -4. The time now is 09:26 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy