linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* How to suspend a thread (without pthread)
@ 2005-05-25  6:11 SVisor
  2005-05-25  6:23 ` Ron Michael Khu
  0 siblings, 1 reply; 3+ messages in thread
From: SVisor @ 2005-05-25  6:11 UTC (permalink / raw)
  To: linux-c-programming

As subject says,

I need to suspend threads (for locking purpose) but I do not want to use 
Posix threads library (pthread). Neither do I want to access __KERNEL__ 
protected parts of the kernel API.

There must be a user accesible API for this. The nearest Ive found is 
sched_yield( ), but it just moves a thread (process) to the end of 
run-queue.

// Jarmo


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How to suspend a thread (without pthread)
  2005-05-25  6:11 How to suspend a thread (without pthread) SVisor
@ 2005-05-25  6:23 ` Ron Michael Khu
  2005-05-25  6:47   ` SVisor
  0 siblings, 1 reply; 3+ messages in thread
From: Ron Michael Khu @ 2005-05-25  6:23 UTC (permalink / raw)
  To: SVisor; +Cc: linux-c-programming

what do u mean by suspend?
sleep/block? if ur looking for a time-based threadsleep
maybe u can make use(improvise) with the select() function.
 
for example:

void threadSleep( int sec )
{
    struct timeval stTimeOut;
    int nSel;

    stTimeOut.tv_sec = sec;         /* Set the number of seconds       */
    stTimeOut.tv_usec = 0;          /* Set the number of micro seconds */

    nSel = select( 0, NULL, NULL, NULL, &stTimeOut);
}

what's wrong with using the pthread library? (ex: pthread_mutex_lock, 
pthread_mutex_unlock)
license issues? client-preference issues? library-comptability?


SVisor wrote:

> As subject says,
>
> I need to suspend threads (for locking purpose) but I do not want to 
> use Posix threads library (pthread). Neither do I want to access 
> __KERNEL__ protected parts of the kernel API.
>
> There must be a user accesible API for this. The nearest Ive found is 
> sched_yield( ), but it just moves a thread (process) to the end of 
> run-queue.
>
> // Jarmo
>
> -
> To unsubscribe from this list: send the line "unsubscribe 
> linux-c-programming" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
>



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How to suspend a thread (without pthread)
  2005-05-25  6:23 ` Ron Michael Khu
@ 2005-05-25  6:47   ` SVisor
  0 siblings, 0 replies; 3+ messages in thread
From: SVisor @ 2005-05-25  6:47 UTC (permalink / raw)
  To: linux-c-programming

Ron Michael Khu wrote:
> what do u mean by suspend?
> sleep/block? if ur looking for a time-based threadsleep
> maybe u can make use(improvise) with the select() function.

I mean sleep until awoken. Ive used a yielding spin lock this far. But 
there must be a better way. I cant use a timer (like select).

...
> what's wrong with using the pthread library? (ex: pthread_mutex_lock, 
> pthread_mutex_unlock)
> license issues? client-preference issues? library-comptability?

pthread doesnt play well with clone( ). LGPL (which is pthread:s licens) 
is not realy a problem (today). But the truth is that I try to avoid 
(L)GPL as much as possible. Especially when writing support code (like 
libraries) which future use is unknown.

// Jarmo

...
>> I need to suspend threads (for locking purpose) but I do not want to 
>> use Posix threads library (pthread). Neither do I want to access 
>> __KERNEL__ protected parts of the kernel API.
>>
>> There must be a user accesible API for this. The nearest Ive found is 
>> sched_yield( ), but it just moves a thread (process) to the end of 
>> run-queue.
...


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-05-25  6:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-05-25  6:11 How to suspend a thread (without pthread) SVisor
2005-05-25  6:23 ` Ron Michael Khu
2005-05-25  6:47   ` SVisor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).