The heavyweight "process model", historically used by Unix systems, including Linux, to split a large system into smaller, more tractable pieces doesn’t always lend itself to embedded environments
owing to substantial computational overhead. POSIX threads, also known as Pthreads, is a multithreading API that looks more like what embedded programmers are used to but runs in a
Unix/Linux environment. This presentation introduces Posix Threads and shows you how to use threads to create more efficient, more responsive programs.
Java and the machine - Martijn Verburg and Kirk PepperdineJAX London
In Terminator 3 - Rise of the Machines, bare metal comes back to haunt humanity, ruthlessly crushing all resistance. This keynote is here to warn you that the same thing is happening to Java and the JVM! Java was designed in a world where there were a wide range of hardware platforms to support. Its premise of Write Once Run Anywhere (WORA) proved to be one of the compelling reasons behind Java's dominance (even if the reality didn't quite meet the marketing hype). However, this WORA property means that Java and the JVM struggled to utilise specialist hardware and operating system features that could make a massive difference in the performance of your application. This problem has recently gotten much, much worse. Due to the rise of multi-core processors, massive increases in main memory and enhancements to other major hardware components (e.g. SSD), the JVM is now distant from utilising that hardware, causing some major performance and scalability issues! Kirk Pepperdine and Martijn Verburg will take you through the complexities of where Java meets the machine and loses. They'll give up some of their hard-won insights on how to work around these issues so that you can plan to avoid termination, unlike some of the poor souls that ran into the T-800...
Python Training in Bangalore | Multi threading | Learnbay.inLearnbayin
Learn Multi threading in Python .How to create threads in Python.
About Race Condition.
Learnbay provides python training in Bangalore for network automation.
The heavyweight "process model", historically used by Unix systems, including Linux, to split a large system into smaller, more tractable pieces doesn’t always lend itself to embedded environments
owing to substantial computational overhead. POSIX threads, also known as Pthreads, is a multithreading API that looks more like what embedded programmers are used to but runs in a
Unix/Linux environment. This presentation introduces Posix Threads and shows you how to use threads to create more efficient, more responsive programs.
Java and the machine - Martijn Verburg and Kirk PepperdineJAX London
In Terminator 3 - Rise of the Machines, bare metal comes back to haunt humanity, ruthlessly crushing all resistance. This keynote is here to warn you that the same thing is happening to Java and the JVM! Java was designed in a world where there were a wide range of hardware platforms to support. Its premise of Write Once Run Anywhere (WORA) proved to be one of the compelling reasons behind Java's dominance (even if the reality didn't quite meet the marketing hype). However, this WORA property means that Java and the JVM struggled to utilise specialist hardware and operating system features that could make a massive difference in the performance of your application. This problem has recently gotten much, much worse. Due to the rise of multi-core processors, massive increases in main memory and enhancements to other major hardware components (e.g. SSD), the JVM is now distant from utilising that hardware, causing some major performance and scalability issues! Kirk Pepperdine and Martijn Verburg will take you through the complexities of where Java meets the machine and loses. They'll give up some of their hard-won insights on how to work around these issues so that you can plan to avoid termination, unlike some of the poor souls that ran into the T-800...
Python Training in Bangalore | Multi threading | Learnbay.inLearnbayin
Learn Multi threading in Python .How to create threads in Python.
About Race Condition.
Learnbay provides python training in Bangalore for network automation.
Advanced Introduction to Java Multi-Threading - Full (chok)choksheak
Designed for the beginning Java developer to grasp advanced Java multi-threading concepts quickly. Talks mainly about the Java Memory Model and the Concurrent Utilities. This presentation is Java-specific and we intentionally omit general non-Java-specific details, such as hardware architecture, OS, native threads, algorithms, and general software design principles etc.
If you've tried Apache Solr 1.4, you've probably had a chance to take it for a spin indexing and searching your data, and getting acquainted with its powerful, versatile new features and functions. Now, it's time to roll up your sleeves and really master what Solr 1.4 has to offer.
Lecture 10 from the IAG0040 Java course in TTÜ.
See the accompanying source code written during the lectures: https://github.com/angryziber/java-course
Advanced Introduction to Java Multi-Threading - Full (chok)choksheak
Designed for the beginning Java developer to grasp advanced Java multi-threading concepts quickly. Talks mainly about the Java Memory Model and the Concurrent Utilities. This presentation is Java-specific and we intentionally omit general non-Java-specific details, such as hardware architecture, OS, native threads, algorithms, and general software design principles etc.
If you've tried Apache Solr 1.4, you've probably had a chance to take it for a spin indexing and searching your data, and getting acquainted with its powerful, versatile new features and functions. Now, it's time to roll up your sleeves and really master what Solr 1.4 has to offer.
Lecture 10 from the IAG0040 Java course in TTÜ.
See the accompanying source code written during the lectures: https://github.com/angryziber/java-course
A thread is an independent flow of control within a process, composed of a context (which includes a
register set and a program counter) and a sequence of instructions to execute.
Comparing Evolved Extractive Text Summary Scores of Bidirectional Encoder Rep...University of Maribor
Slides from:
11th International Conference on Electrical, Electronics and Computer Engineering (IcETRAN), Niš, 3-6 June 2024
Track: Artificial Intelligence
https://www.etran.rs/2024/en/home-english/
Richard's aventures in two entangled wonderlandsRichard Gill
Since the loophole-free Bell experiments of 2020 and the Nobel prizes in physics of 2022, critics of Bell's work have retreated to the fortress of super-determinism. Now, super-determinism is a derogatory word - it just means "determinism". Palmer, Hance and Hossenfelder argue that quantum mechanics and determinism are not incompatible, using a sophisticated mathematical construction based on a subtle thinning of allowed states and measurements in quantum mechanics, such that what is left appears to make Bell's argument fail, without altering the empirical predictions of quantum mechanics. I think however that it is a smoke screen, and the slogan "lost in math" comes to my mind. I will discuss some other recent disproofs of Bell's theorem using the language of causality based on causal graphs. Causal thinking is also central to law and justice. I will mention surprising connections to my work on serial killer nurse cases, in particular the Dutch case of Lucia de Berk and the current UK case of Lucy Letby.
The use of Nauplii and metanauplii artemia in aquaculture (brine shrimp).pptxMAGOTI ERNEST
Although Artemia has been known to man for centuries, its use as a food for the culture of larval organisms apparently began only in the 1930s, when several investigators found that it made an excellent food for newly hatched fish larvae (Litvinenko et al., 2023). As aquaculture developed in the 1960s and ‘70s, the use of Artemia also became more widespread, due both to its convenience and to its nutritional value for larval organisms (Arenas-Pardo et al., 2024). The fact that Artemia dormant cysts can be stored for long periods in cans, and then used as an off-the-shelf food requiring only 24 h of incubation makes them the most convenient, least labor-intensive, live food available for aquaculture (Sorgeloos & Roubach, 2021). The nutritional value of Artemia, especially for marine organisms, is not constant, but varies both geographically and temporally. During the last decade, however, both the causes of Artemia nutritional variability and methods to improve poorquality Artemia have been identified (Loufi et al., 2024).
Brine shrimp (Artemia spp.) are used in marine aquaculture worldwide. Annually, more than 2,000 metric tons of dry cysts are used for cultivation of fish, crustacean, and shellfish larva. Brine shrimp are important to aquaculture because newly hatched brine shrimp nauplii (larvae) provide a food source for many fish fry (Mozanzadeh et al., 2021). Culture and harvesting of brine shrimp eggs represents another aspect of the aquaculture industry. Nauplii and metanauplii of Artemia, commonly known as brine shrimp, play a crucial role in aquaculture due to their nutritional value and suitability as live feed for many aquatic species, particularly in larval stages (Sorgeloos & Roubach, 2021).
Nucleophilic Addition of carbonyl compounds.pptxSSR02
Nucleophilic addition is the most important reaction of carbonyls. Not just aldehydes and ketones, but also carboxylic acid derivatives in general.
Carbonyls undergo addition reactions with a large range of nucleophiles.
Comparing the relative basicity of the nucleophile and the product is extremely helpful in determining how reversible the addition reaction is. Reactions with Grignards and hydrides are irreversible. Reactions with weak bases like halides and carboxylates generally don’t happen.
Electronic effects (inductive effects, electron donation) have a large impact on reactivity.
Large groups adjacent to the carbonyl will slow the rate of reaction.
Neutral nucleophiles can also add to carbonyls, although their additions are generally slower and more reversible. Acid catalysis is sometimes employed to increase the rate of addition.
DERIVATION OF MODIFIED BERNOULLI EQUATION WITH VISCOUS EFFECTS AND TERMINAL V...Wasswaderrick3
In this book, we use conservation of energy techniques on a fluid element to derive the Modified Bernoulli equation of flow with viscous or friction effects. We derive the general equation of flow/ velocity and then from this we derive the Pouiselle flow equation, the transition flow equation and the turbulent flow equation. In the situations where there are no viscous effects , the equation reduces to the Bernoulli equation. From experimental results, we are able to include other terms in the Bernoulli equation. We also look at cases where pressure gradients exist. We use the Modified Bernoulli equation to derive equations of flow rate for pipes of different cross sectional areas connected together. We also extend our techniques of energy conservation to a sphere falling in a viscous medium under the effect of gravity. We demonstrate Stokes equation of terminal velocity and turbulent flow equation. We look at a way of calculating the time taken for a body to fall in a viscous medium. We also look at the general equation of terminal velocity.
Observation of Io’s Resurfacing via Plume Deposition Using Ground-based Adapt...Sérgio Sacani
Since volcanic activity was first discovered on Io from Voyager images in 1979, changes
on Io’s surface have been monitored from both spacecraft and ground-based telescopes.
Here, we present the highest spatial resolution images of Io ever obtained from a groundbased telescope. These images, acquired by the SHARK-VIS instrument on the Large
Binocular Telescope, show evidence of a major resurfacing event on Io’s trailing hemisphere. When compared to the most recent spacecraft images, the SHARK-VIS images
show that a plume deposit from a powerful eruption at Pillan Patera has covered part
of the long-lived Pele plume deposit. Although this type of resurfacing event may be common on Io, few have been detected due to the rarity of spacecraft visits and the previously low spatial resolution available from Earth-based telescopes. The SHARK-VIS instrument ushers in a new era of high resolution imaging of Io’s surface using adaptive
optics at visible wavelengths.
Nutraceutical market, scope and growth: Herbal drug technologyLokesh Patil
As consumer awareness of health and wellness rises, the nutraceutical market—which includes goods like functional meals, drinks, and dietary supplements that provide health advantages beyond basic nutrition—is growing significantly. As healthcare expenses rise, the population ages, and people want natural and preventative health solutions more and more, this industry is increasing quickly. Further driving market expansion are product formulation innovations and the use of cutting-edge technology for customized nutrition. With its worldwide reach, the nutraceutical industry is expected to keep growing and provide significant chances for research and investment in a number of categories, including vitamins, minerals, probiotics, and herbal supplements.
The ability to recreate computational results with minimal effort and actionable metrics provides a solid foundation for scientific research and software development. When people can replicate an analysis at the touch of a button using open-source software, open data, and methods to assess and compare proposals, it significantly eases verification of results, engagement with a diverse range of contributors, and progress. However, we have yet to fully achieve this; there are still many sociotechnical frictions.
Inspired by David Donoho's vision, this talk aims to revisit the three crucial pillars of frictionless reproducibility (data sharing, code sharing, and competitive challenges) with the perspective of deep software variability.
Our observation is that multiple layers — hardware, operating systems, third-party libraries, software versions, input data, compile-time options, and parameters — are subject to variability that exacerbates frictions but is also essential for achieving robust, generalizable results and fostering innovation. I will first review the literature, providing evidence of how the complex variability interactions across these layers affect qualitative and quantitative software properties, thereby complicating the reproduction and replication of scientific studies in various fields.
I will then present some software engineering and AI techniques that can support the strategic exploration of variability spaces. These include the use of abstractions and models (e.g., feature models), sampling strategies (e.g., uniform, random), cost-effective measurements (e.g., incremental build of software configurations), and dimensionality reduction methods (e.g., transfer learning, feature selection, software debloating).
I will finally argue that deep variability is both the problem and solution of frictionless reproducibility, calling the software science community to develop new methods and tools to manage variability and foster reproducibility in software systems.
Exposé invité Journées Nationales du GDR GPL 2024
Seminar of U.V. Spectroscopy by SAMIR PANDASAMIR PANDA
Spectroscopy is a branch of science dealing the study of interaction of electromagnetic radiation with matter.
Ultraviolet-visible spectroscopy refers to absorption spectroscopy or reflect spectroscopy in the UV-VIS spectral region.
Ultraviolet-visible spectroscopy is an analytical method that can measure the amount of light received by the analyte.
2. 2
3
P threads (POSIX)
(see https://computing.llnl.gov/tutorials/pthreads/)
4
The Pthread API
• Pthreads has emerged as the standard threads API, supported by most
vendors.
• The concepts discussed here are largely independent of the API and can be
used for programming with other thread APIs (NT threads, Solaris threads,
Java threads, etc.) as well.
• Provides two basic functions for specifying concurrency:
#include <pthread.h>
int pthread_create (pthread_t * thread_p,
const pthread_attr_t * attribute,
void (*thread_function)(void *),
void *arg_p);
int pthread_join (pthread_t thread_p,
void * *ptr);
declares the various Pthreads
functions, constants, types, etc.
Wait for the thread associated
with thread_p to complete
Create a thread identified
by a thread handle
7. 7
13
Mutual Exclusion
• Critical sections in Pthreads are implemented using mutex locks.
• Mutex-locks have two states: locked and unlocked. At any point of time,
only one thread can lock a mutex lock. A lock is an atomic operation.
• A thread entering a critical section first tries to get a lock. It goes ahead
when the lock is granted.
• The API provides the following functions for handling mutex-locks:
int pthread_mutex_init ( pthread_mutex_t *mutex_lock,
const pthread_mutexattr_t *lock_attr);
int pthread_mutex_lock ( pthread_mutex_t *mutex_lock);
int pthread_mutex_unlock (pthread_mutex_t *mutex_lock);
14
Types of Mutexes
• Pthreads supports three types of mutexes.
– A normal mutex deadlocks if a thread that already has a lock
tries a second lock on it.
– A recursive mutex allows a single thread to lock a mutex as
many times as it wants. It simply increments a count on the
number of locks. A lock is relinquished by a thread when the
count becomes zero.
– An error check mutex reports an error when a thread with a lock
tries to lock it again (as opposed to deadlocking in the first case,
or granting the lock, as in the second case).
• The type of the mutex can be set in the attributes object before it is
passed at time of initialization.
8. 8
15
Attributes Objects for Mutexes
• Initialize the attrributes object using function:
pthread_mutexattr_init (pthread_mutexattr_t *attr) ;
• The function pthread_mutexattr_settype_np can be used for setting the type
of mutex specified by the mutex attributes object.
pthread_mutexattr_settype_np ( pthread_mutexattr_t *attr, int type);
• Here, type specifies the type of the mutex and can take one of:
– PTHREAD_MUTEX_NORMAL_NP
– PTHREAD_MUTEX_RECURSIVE_NP
– PTHREAD_MUTEX_ERRORCHECK_NP
16
Controlling Thread Attributes
• In general, the Pthreads API allows a programmer to change the default attributes
of entities using attributes objects.
• An attributes object is a data-structure that describes entity (thread, mutex,
condition variable) properties.
• Once these properties are set, the attributes object can be passed to the method
initializing the entity.
• Enhances modularity, readability, and ease of modification.
• Use pthread_attr_init to create an attributes object.
• Individual properties associated with the attributes object can be changed using the
following functions:
pthread_attr_setdetachstate,
pthread_attr_setguardsize_np,
pthread_attr_setstacksize,
pthread_attr_setinheritsched,
pthread_attr_setschedpolicy,
pthread_attr_setschedparam
15. 15
29
Producer-Consumer Using Locks
The producer-consumer scenario imposes the following constraints:
• The producer thread must not overwrite the shared buffer when the
previous task has not been picked up by a consumer thread.
• The consumer threads must not pick up tasks until there is something
present in the shared data structure.
• Individual consumer threads should pick up tasks one at a time.
Buffer - Queue
(one value)
producer consumer
consumer
consumer
producer
producer
We can start with the assumption that there is one producer and one consumer
30
Producer-Consumer implementation
/* Producer */
while (!done()) {
create_task (&my_task);
while (task_available == 1) ; /* wait until buffer is empty */
insert_into_queue(&my_task); /* put task in buffer */
task_available = 1; /* indicate that buffer is occupied*/
}
/* Consumer */
while (!done()) {
while (task_available == 0) ; /* wait until buffer is full */
extract_from_queue(&my_task); /* consume task from buffer */
task_available = 0; /* indicate that buffer is not occupied */
process_task(&my_task) ;
}
What is wrong with this implementation?
lock
unlock
lock
unlock
16. 16
31
A fix for the Producer-Consumer program
/* Producer */
while (!done()) {
create_task (&my_task);
inserted = 0 ; /* to flag successful insertion */
while (inserted == 0) {
pthread_mutex_lock (&task_queue_lock);
if (task_available == 0) {
insert_into_queue(my_task);
task_available = 1;
inserted = 1; }
pthread_mutex_unlock(&task_queue_lock);
}
/* Consumer */
while (!done()) {
extracted = 0; /* to flag success extraction */
while (extracted == 0) {
pthread_mutex_lock (&task_queue_lock);
if (task_available == 1) {
extract_from_queue(&my_task);
task_available = 0;
extracted = 1 ;}
pthread_mutex_unlock(&task_queue_lock);
}
process_task(&my_task);
}
32
Producer-Consumer Using Locks
pthread_mutex_t task_queue_lock;
int task_available;
...
main() {
....
task_available = 0;
pthread_mutex_init (&task_queue_lock, NULL);
Create producer threads and consumer threads ;
}
void *producer (void *producer_thread_data) {
int inserted;
struct task my_task;
while (!done()) {
create_task (&my_task); /* a procedure that produces a data structure for a new task */
inserted = 0;
while (inserted == 0) {
pthread_mutex_lock (&task_queue_lock);
if (task_available == 0) { /* if buffer is empty */
insert_into_queue(&my_task); /* put task in buffer */
task_available = 1; /* indicate that buffer is occupied */
inserted = 1; /* and that insertion is successful */
}
pthread_mutex_unlock(&task_queue_lock);
}
}
}
18. 18
35
Condition Variables for Synchronization (signals)
• A condition variable allows a thread to block itself until a specified condition
becomes true.
• When a thread executes
pthread_cond_wait(condition_variable),
it is blocked until another thread executes
pthread_cond_signal(condition_variable) or
pthread_cond_broadcast(condition_variable)
• pthread_cond_signal () is used to unblock one of the threads blocked waiting on
the condition_variable.
• pthread_cond_broadcast() is used to unblock all the threads blocked waiting on
the condition_variable.
• If no threads are waiting on the condition variable, then a pthread-cond_signal()
or pthread-cond_broadcast() will have no effect.
36
Condition Variables for Synchronization
int pthread_cond_init (pthread_cond_t *cond, const pthread_condattr_t *attr);
int pthread_cond_wait (pthread_cond_t *cond, pthread_mutex_t *mutex);
int pthread_cond_signal (pthread_cond_t *cond);
int pthread_cond_broadcast (pthread_cond_t *cond);
int pthread_cond_destroy (pthread_cond_t *cond);
• A condition variable always has a mutex associated with it. A thread locks this
mutex before issuing a wait, a signal or a broadcast.
• While the thread is waiting on a condition variable, the mutex is automatically
unlocked, and when the thread is signaled, the mutex is automatically locked
again.
• Pthreads provides the following functions for condition variables
19. 19
37
Typical use of condition variables
We will see an example later.
38
Synchronization (barriers)
int main(int argc, char *argv) {
double A[5] , B[5], C[5] ; /* global, shared variables*/
for (i = 0; i < 5 ; i++) A[i] = B[i] = 1 ;
for (i = 0; i < 4 ; i++) pthread_create( … , DoStuff, int i ) ;
…
for (i = 0; i < 4 ; i++) pthread_join (… , DoStuff, …) ;
Print the values of C ;
}
void DoStuff (int threadID) {
int k ;
B[threadID+1] = 2 * A[threadID] ;
…..
C[threadID] = 2 * B[threadID] ;
}
What is the output of the following Pthread program??
Barrier
A 1 1 1 1 1
B 1 1 1 1 1
B 1 2 2 2 2
C 2 4 4 4 2
20. 20
39
• A barrier holds a thread until all threads participating in the barrier have
reached it.
• Barriers can be implemented using a counter, a mutex and a condition
variable.
• A single integer (counter) is used to keep track of the number of threads that
have reached the barrier.
• If the count is less than the total number of threads, the threads execute a
condition wait.
• The last thread entering (and setting the count to the number of threads)
wakes up all the threads using a condition broadcast and resets the count to
zero (to prepare for the next barrier).
Barriers - a composite synchronization construct
• By design, Pthreads provide support for a basic set of operations.
• Higher level constructs can be built using basic synchronization constructs.
• We discuss one such constructs - barriers.
40
Defining your own barrier construct
typedef struct {
pthread_mutex_t count_lock;
pthread_cond_t ok_to_proceed;
int count;
} mylib_barrier_t;
void mylib_init_barrier (mylib_barrier_t *b) {
b.count = 0;
pthread_mutex_init (&(b.count_lock), NULL);
pthread_cond_init (&(b.ok_to_proceed), NULL);
}
void mylib_barrier (mylib_barrier_t *b, int thread_count) {
pthread_mutex_lock (&(b.count_lock));
b.count ++;
if (b.count == thread_count) {
b.count = 0;
pthread_cond_broadcast (&(b.ok_to_proceed));
}
else
pthread_cond_wait (&(b.ok_to_proceed), &(b.count_lock)) ;
pthread_mutex_unlock(&(b.count_lock));
}
21. 21
41
Using the defined barrier
mylib_barrier_t my_barrier ; /*declare a barrier */
int main(int argc, char *argv) {
mylib_init_barrier (my_barrier) ; /* initialize the barrier */
double A[5] , B[5], C[5] ; /* global, shared variables*/
for (i = 0; i < 5 ; i++) A[i] = B[i] = 1 ;
for (i = 0; i < 4 ; i++) pthread_create( … , DoStuff, int i ) ;
for (i = 0; i < 4 ; i++) pthread_join (… , DoStuff, …) ;
Print the values of C ;
}
void DoStuff (int threadID) {
int k ;
B[threadID+1] = 2 * A[threadID] ;
mylib_barrier ( my_barrier, 4) ; /* call the barrier */
C[threadID] = 2 * B[threadID] ;
}
42
Implementing barriers using busy waiting
We need one counter
variable for each
instance of the barrier,
otherwise problems
are likely to occur.