pthread create해서 "ps -ef" 하면

익명 사용자의 이미지

궁금한게 있어서 올려봅니다.
제가 thread에 대한 개념이 아직 부족해서 이런 질문을 하는지도 모르겠군요.. ㅡㅡ;

다음과 같이 간단히 thread를 2개 생성하였습니다.
//------- thread.c
void * thread_function(void *arg)
{
int i;
i = (int)arg;
sleep(i);
pthread_exit("thread_function exit");
}

void * thread_function1(void *arg)
{
int i;
i = (int)arg;
sleep(i);
pthread_exit("thread_function1 exit");
}

main()
{
int i;
pthread_t a_thread, b_thread;
void *thread_result;
void *thread_result1;

pthread_create(&a_thread, NULL, thread_function, (void *)10);
pthread_create(&b_thread, NULL, thread_function1, (void *)10);

printf("Waiting for thread to finish...\n");
pthread_join(a_thread, &thread_result);
pthread_join(b_thread, &thread_result1);

exit(0);
}

실행하고나서 ps -ef로 보면 다음과 같은 결과가 나옵니다.
//----- 결과
mint 1519 900 0 0954 pts/1 000000 ./thread
mint 1520 1519 0 0954 pts/1 000000 ./thread
mint 1521 1520 0 0954 pts/1 000000 ./thread
mint 1522 1520 0 0954 pts/1 000000 ./thread

결과가.. 좀.. ^^ 다른 시스템에서 해보면 thread 하나만 보입니다.
헌데 리눅스에서만 하면 생성하려는 thread 개수에 2개가 더한 결과가 나옵니다.
hp나 solaris에서는 하나만 보이구요

왜 이런 결과가 나올까요?
시스템마다 process관리 정책이 틀리고 ps utility도 달라서 생기는 문제일가요?
그럼, 다른 시스템에서도 thread list를 볼 수 있고, linux에서는 여러개의 thread를 포함한 하나의
process를 볼 수 있게 할수도 있을거 같기도 한데.. ㅡㅡ;
음... 다 아시고 계시는데 저만 모르고 있었던게 아닐까 해서 질답에 올리기 좀 걱정스럽군요..^^
그럼 아시는분 답변 해주세요..

익명 사용자의 이미지

http//kldp.org/script/bbs/read.php?table=qa2&no=3628

익명 사용자의 이미지

이런~.. 좀더 검색해 볼껄.. 그랬습니다.
Thread Manager는 system level(??) 이겠군요. 그래서 kill로는 종
료가 안 되는것 같던데..
헌데 ps -ef f나 ps -ef로 볼때 solaris처럼 main thread만 보이게
할 수는 없나요?
것도 알려주신 사이트에 있나요?.. 좀 자세히 봐야겠군요.. ^^
이궁.. ㅡㅡ;

감사합니다.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.