How to change the scope of an thread in Linux? - linux-kernel

i am trying to create an program which sets the scope of an POSIX thread in linux .. I am using pthread_attr_setscope() for setting the scope of the thread to process context but it is set to default as system. Is there any way to change the thread scope in linux ? I am using Ubuntu with a 3.8.2 kernel

This is not implemented in the Linux kernel.
glibc's pthread_attr_setscope stores the setting in the pthread_attr structure so that it can be retrieved later with pthread_attr_getscope, but that's all it does.

Related

setup environment in u-boot SPL

Is there any option to load the environment variables in u-boot SPL?
I have a device (Arria10 SoC) in which a part of the FPGA firmware is loaded in u-boot SPL by using the Firmware Loader API.
This allows the usage of the environment variables storage_interface and fw_dev_part to define the storage.
I was able to set the variables in u-boot and store them to the MMC device. u-boot also reads the variables correct. But in SPL the environment variables aren't initialized.
Is it possible to load it in SPL and use the values from MMC?
Thanks for any hint!
The environment is initialized by calling env_init(). Other boards call this function in the board or architecture specific spl.c file in either of the following functions:
board_boot_order()
board_init_f()
board_init_r()
spl_start_uboot()
Just grep for 'env_init(' to find the code locations.
You will have to implement one of the functions.

CANalyzer CAPL: determine if bus sleep (no messages on bus)

I am using CANalyzer 7.0 and an trying to figure out how to determine in CAPL if the CAN bus has gone to sleep (no more messages being sent). How can I do this?
I tried to read BusLoad using sysGetVariableInt() but it always returned zero. Perhaps I had the wrong namespace/variable name. Where can I find all system variables?
Edit - I've tried this:
BusLoad = sysGetVariableInt("_Statistics", "CAN1::Busload");
I've also tried changing the namespace but not sure where to find list of system namespaces.
Accessing statistics via system variables was introduced with CANalyzer/CANoe version 8.0.
As your are using version 7.0, try the following:
BusLoad = canGetBusLoad(1);
Starting from version 7.1, you would use:
BusLoad = CAN1.BusLoad;
From 8.0 onwards, you can use the systemvariables as in your initial question.
To answer your second question, you can get a list of all system variables from the Symbol Explorer.

Permanently blacklist linux kernel module

I have pcspkr in blacklisted in /etc/modprobe.d/pcspkr.conf. However, I can manually load the module using modprobe.
I'm guessing, some other component will be able to do the same via module alias mechanism. Is there a way to permanently block automatic loading of a specific kernel module?
My use case is that I want to experiment with an alternative driver than the one provided in-tree. For this, I do not want the system's default driver showing up. I do not want to delete the golden driver provided by the kernel and screw up either.
What options do I have ?

How does Linux kernel parse vga= parameter?

I want to boot my Linux 3.18.48 compiled from source, with resolution 640x480. So I'm passing it a parameter vga=0x312. For some reason, it doesn't work.
To understand what's happening, I grep'ed the kernel source for "vga=", expecting some macro __setup("vga=", function_ptr), similar to other kernel cmdline parameters (video=, root=, etc).
However, there's no such occurrence.
So how does the Linux kernel parse vga= parameter?
According to the docs:
vga= [BOOT,X86-32] Select a particular video mode
...
This is actually a boot loader parameter; the value is
passed to the kernel using a special protocol.
So the kernel does not parse this parameter at all. In my case it's GRUB 2.02 parsing this parameter and passing to the kernel through variable gfxpayload, as listed in GRUB's linux command.
Now I can continue investigating why vga= parameter is being ignored, looking at GRUB's source :-)
EDIT
vga= is parsed by GRUB only on legacy BIOS systems.
That's why vga= is being ignored on my machine. Since I'm using a UEFI system, I need to set the gfxpayload variable directly:
set gfxpayload=640x480
Now it sets the resolution correctly.

C++ daemon forking causes mysql errors

I have a daemon that forks the process.
This daemon access a database using mysql connector library.
When I do not fork, I am able to open and read a database fine, however, when I fork, I get
MySQL server has gone away
errors consistently on the first query...
Anyone know what could be causing this?
Edit Oh, my apologies for misinterpreting
Still the problems with differences between daemonized/non-daemonized are roughly with the following class of options:
environment variables
LIBPATH
PATH
HOME, UID, EUID (HOME surprisingly enough gets (ab)used way too often)
mysql specific variables
permissions
what user is the daemon running as? elevated or privilege separation?
current working directory (traditionally / for daemons, where / might be a chroot jail instead of 'real' /)
Starting with kernel 2.4.19, Linux provides per-process mount namespaces. A
mount namespace is the set of file system mounts that are visible to a
process. Mount-point namespaces can be (and usually are) shared between
multiple processes, and changes to the namespace (i.e., mounts and unmounts)
by one process are visible to all other processes sharing the same namespace.
(The pre-2.4.19 Linux situation can be considered as one in which a single
namespace was shared by every process on the system.)
detached stdin/stdout causing trouble (IMO that would mean badly designed library, but who am I)
watch it that specific resources (file locks, socket connections, threads (!)) are NOT inherited across fork/execve. I recommend reading the linked on daemonization (below), especially for example the section on 'Mutual Exclusion and Running a Single Copy [open,lockf,getpid]'
I'm sure I'm forgetting stuff
Ermm... what are you starting a mysql server process for? Mysql has plenty of sound init scripts that do work.
On the subject of proper daemonization: http://www.enderunix.org/docs/eng/daemon.php
Pay attention to the effects of sharing resources with fork children (e.g. file descriptors).
Besides that, you could just be missing basic environment settings. Peruse the official init scripts for mysql to find out which you need.

Resources