Skip to contentSkip to conversation

About getopt()

DISCUSSION William N. Zanatta 3 participants 5 messages Aug 8, 2002 – Aug 15, 2002

lore
Share & tools
lore
#0 lore raw

Hey,

getopt() does memory allocation for the optarg pointer it sets when a
value for it is found, right?
ok, thus if I'm making something like

char *str;
...

  str = optarg;

I'll have to free() str later.

Is that right???

Thanks,

william

Signature · 2 lines
Perl combines all of the worst aspects of BASIC, C and line noise.
                -- Keith Packard
#1 lore raw
Quoted 2 lines · William N. Zanatta

getopt() does memory allocation for the optarg pointer it sets when a
value for it is found, right?

No. optarg will point at or into one of the elements of argv.

E.g. for "./foo -a hello", optarg will be equal to argv[2], while for "./foo -ahello", optarg will be equal to argv[1]+2.

Signature · 1 line
Glynn Clements <[email protected]>
#2 lore raw

finer grained threading?

In reply to William N. Zanatta

hi list,

I have been wondering about what happens to a locked resource within a set of kernel threads when the holding thread causes a page fault, say via touching a page of a mmap'ed file.

As far as I can see, there is no system call API means for the thread/process to take remedial action when this I/O delay occurs - ie. it could be useful for the holding thread to yield its lock on the resource, allowing other threads to progress while it sleeps.

Does anyone know otherwise?

Is there any mechanism in the kernel allowing notification of a page fault event (or indeed other I/O related events) to be received by, say, some code encapsulated in a kernel module? ie. would writing a kernel module be any sort of option for me?

hope that's clear.
thanks,
chris Q.

#3 lore raw

Re: finer grained threading?

Ah! As suspected I am not the first to think about this! I have just found a DECthreads page mentioning upcalls and the ability to switch threads on a page fault event.

Is it correct to say LinuxThreads(pthreads impl.) cannot offer this feature? Any suggestions for alternative thread packages for linux that do?

cheers,
chris Q.

Quoted 20 lines · Christopher Quinn

hi list,

I have been wondering about what happens to a locked resource within a set of kernel threads when the holding thread causes a page fault, say via touching a page of a mmap'ed file.

As far as I can see, there is no system call API means for the thread/process to take remedial action when this I/O delay occurs - ie. it could be useful for the holding thread to yield its lock on the resource, allowing other threads to progress while it sleeps.

Does anyone know otherwise?

Is there any mechanism in the kernel allowing notification of a page fault event (or indeed other I/O related events) to be received by, say, some code encapsulated in a kernel module? ie. would writing a kernel module be any sort of option for me?

hope that's clear.
thanks,
chris Q.

-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 2 lines
rgrds,
Chris Quinn
#4 lore raw

Re: finer grained threading?

I'm tripping over myself...
the 'feature' I'm after is as originally stated, not as might or might not be fulfilled by DECthreads/LinuxThreads ie. ability to register interest in/ receive noticification of, page-fault events.

sorry,
chris

Quoted 8 lines · Christopher Quinn

Ah! As suspected I am not the first to think about this! I have just found a DECthreads page mentioning upcalls and the ability to switch threads on a page fault event.

Is it correct to say LinuxThreads(pthreads impl.) cannot offer this feature? Any suggestions for alternative thread packages for linux that do?

cheers,
chris Q.