Search results
- Protocols are to communication what algorithms or programming languages are to computations. Operating systems usually contain a set of cooperating processes that manipulate shared data to communicate with each other. This communication is governed by well-understood protocols, which can be embedded in the process code itself.
en.wikipedia.org › wiki › Communication_protocol
Top results related to what are protocols in operating systems in computer
Top Answer
Answered Nov 16, 2016 · 1 votes
Always try to read Linux documentation(man <command or system_call>) for these type of doubts.
for your case man sem_init
sem_init() initializes the unnamed semaphore at the address pointed to by sem. The value argument specifies the initial value for the semaphore.
web link of the man pages
1/5
Top Answer
Answered May 29, 2021 · 146 votes
Linux x86 ring usage overview
Understanding how rings are used in Linux will give you a good idea of what they are designed for.
In x86 protected mode, the CPU is always in one of 4 rings. The Linux kernel only uses 0 and 3:
- 0 for kernel
- 3 for users
This is the most hard and fast definition of kernel vs userland.
Why Linux does not use rings 1 and 2: CPU Privilege Rings: Why rings 1 and 2 aren't used?
How is the current ring determined?
The current ring is selected by a combination of:
- global descriptor table: a in-memory table of GDT entries, and each entry has a field Privl which encodes the ring.The LGDT instruction sets the address to the current descriptor table.See also: http://wiki.osdev.org/Global_Descriptor_Table
- the segment registers CS, DS, etc., which point to the index of an entry in the GDT.For example, CS = 0 means the first entry of the GDT is currently active for the executing code.
What can each ring do?
The CPU chip is physically built so that:
- ring 0 can do anything
- ring 3 cannot run several instructions and write to several registers, most notably: cannot change its own ring! Otherwise, it could set itself to ring 0 and rings would be useless.In other words, cannot modify the current segment descriptor, which determines the current ring.
- cannot modify the page tables: How does x86 paging work?In other words, cannot modify the CR3 register, and paging itself prevents modification of the page tables.This prevents one process from seeing the memory of other processes for security / ease of programming reasons.
- cannot register interrupt handlers. Those are configured by writing to memory locations, which is also prevented by paging.Handlers run in ring 0, and would break the security model.In other words, cannot use the LGDT and LIDT instructions.
- cannot do IO instructions like in and out , and thus have arbitrary hardware accesses.Otherwise, for example, file permissions would be useless if any program could directly read from disk.More precisely thanks to Michael Petch: it is actually possible for the OS to allow IO instructions on ring 3, this is actually controlled by the Task state segment.What is not possible is for ring 3 to give itself permission to do so if it didn't have it in the first place.Linux always disallows it. See also: Why doesn't Linux use the hardware context switch via the TSS?
How do programs and operating systems transition between rings?
- when the CPU is turned on, it starts running the initial program in ring 0 (well kind of, but it is a good approximation). You can think this initial program as being the kernel (but it is normally a bootloader that then calls the kernel still in ring 0).
- when a userland process wants the kernel to do something for it like write to a file, it uses an instruction that generates an interrupt such as int 0x80 or syscall to signal the kernel. x86-64 Linux syscall hello world example:
.datahello_world: .ascii "hello world\n" hello_world_len = . - hello_world.text.global _start_start: /* write */ mov $1, %rax mov $1, %rdi mov $hello_world, %rsi mov $hello_world_len, %rdx syscall- /* exit */ mov $60, %rax mov $0, %rdi syscall-
compile and run:
as -o hello_world.o hello_world.Sld -o hello_world.out hello_world.o./hello_world.out-
GitHub upstream.
When this happens, the CPU calls an interrupt callback handler which the kernel registered at boot time. Here is a concrete baremetal example that registers a handler and uses it.
This handler runs in ring 0, which decides if the kernel will allow this action, do the action, and restart the userland program in ring 3. x86_64
- when the exec system call is used (or when the kernel will start /init), the kernel prepares the registers and memory of the new userland process, then it jumps to the entry point and switches the CPU to ring 3
- If the program tries to do something naughty like write to a forbidden register or memory address (because of paging), the CPU also calls some kernel callback handler in ring 0.But since the userland was naughty, the kernel might kill the process this time, or give it a warning with a signal.
- When the kernel boots, it setups a hardware clock with some fixed frequency, which generates interrupts periodically.This hardware clock generates interrupts that run ring 0, and allow it to schedule which userland processes to wake up.This way, scheduling can happen even if the processes are not making any system calls.
What is the point of having multiple rings?
There are two major advantages of separating kernel and userland:
- it is easier to make programs as you are more certain one won't interfere with the other. E.g., one userland process does not have to worry about overwriting the memory of another program because of paging, nor about putting hardware in an invalid state for another process.
- it is more secure. E.g. file permissions and memory separation could prevent a hacking app from reading your bank data. This supposes, of course, that you trust the kernel.
How to play around with it?
I've created a bare metal setup that should be a good way to manipulate rings directly: https://github.com/cirosantilli/x86-bare-metal-examples
I didn't have the patience to make a userland example unfortunately, but I did go as far as paging setup, so userland should be feasible. I'd love to see a pull request.
Alternatively, Linux kernel modules run in ring 0, so you can use them to try out privileged operations, e.g. read the control registers: How to access the control registers cr0,cr2,cr3 from a program? Getting segmentation fault
Here is a convenient QEMU + Buildroot setup to try it out without killing your host.
The downside of kernel modules is that other kthreads are running and could interfere with your experiments. But in theory you can take over all interrupt handlers with your kernel module and own the system, that would be an interesting project actually.
Negative rings
While negative rings are not actually referenced in the Intel manual, there are actually CPU modes which have further capabilities than ring 0 itself, and so are a good fit for the "negative ring" name.
One example is the hypervisor mode used in virtualization.
For further details see:
- https://security.stackexchange.com/questions/129098/what-is-protection-ring-1
- https://security.stackexchange.com/questions/216527/ring-3-exploits-and-existence-of-other-rings
ARM
In ARM, the rings are called Exception Levels instead, but the main ideas remain the same.
There exist 4 exception levels in ARMv8, commonly used as:
.text.global _start_start: /* write */ mov x0, 1 ldr x1, =msg ldr x2, =len mov x8, 64 svc 0- /* exit */ mov x0, 0 mov x8, 93 svc 0msg: .ascii "hello syscall v8\n"len = . - msg-
sudo apt-get install qemu-user gcc-arm-linux-gnueabihfarm-linux-gnueabihf-as -o hello.o hello.Sarm-linux-gnueabihf-ld -o hello hello.oqemu-arm hello-
- EL0: userland
- EL1: kernel ("supervisor" in ARM terminology).Entered with the svc instruction (SuperVisor Call), previously known as swi before unified assembly, which is the instruction used to make Linux system calls. Hello world ARMv8 example:hello.S .text.global _start_start: /* write */ mov x0, 1 ldr x1, =msg ldr x2, =len mov x8, 64 svc 0 /* exit */ mov x0, 0 mov x8, 93 svc 0msg: .ascii "hello syscall v8\n"len = . - msgGitHub upstream.Test it out with QEMU on Ubuntu 16.04: sudo apt-get install qemu-user gcc-arm-linux-gnueabihfarm-linux-gnueabihf-as -o hello.o hello.Sarm-linux-gnueabihf-ld -o hello hello.oqemu-arm helloHere is a concrete baremetal example that registers an SVC handler and does an SVC call.
- EL2: hypervisors, for example Xen.Entered with the hvc instruction (HyperVisor Call).A hypervisor is to an OS, what an OS is to userland.For example, Xen allows you to run multiple OSes such as Linux or Windows on the same system at the same time, and it isolates the OSes from one another for security and ease of debug, just like Linux does for userland programs.Hypervisors are a key part of today's cloud infrastructure: they allow multiple servers to run on a single hardware, keeping hardware usage always close to 100% and saving a lot of money.AWS for example used Xen until 2017 when its move to KVM made the news.
- EL3: yet another level. TODO example.Entered with the smc instruction (Secure Mode Call)
The ARMv8 Architecture Reference Model DDI 0487C.a - Chapter D1 - The AArch64 System Level Programmer's Model - Figure D1-1 illustrates this beautifully:
The ARM situation changed a bit with the advent of ARMv8.1 Virtualization Host Extensions (VHE). This extension allows the kernel to run in EL2 efficiently:
VHE was created because in-Linux-kernel virtualization solutions such as KVM have gained ground over Xen (see e.g. AWS' move to KVM mentioned above), because most clients only need Linux VMs, and as you can imagine, being all in a single project, KVM is simpler and potentially more efficient than Xen. So now the host Linux kernel acts as the hypervisor in those cases.
From the image we can see that when the bit E2H
of register HCR_EL2
equals 1, then VHE is enabled, and:
- the Linux kernel runs in EL2 instead of EL1
- when HCR_EL2.TGE == 1, we are a regular host userland program. Using sudo can destroy the host as usual.
- when HCR_EL2.TGE == 0 we are a guest OS (e.g. when you run an Ubuntu OS inside QEMU KVM inside the host Ubuntu. Doing sudo cannot destroy the host unless there's a QEMU/host kernel bug.
Note how ARM, maybe due to the benefit of hindsight, has a better naming convention for the privilege levels than x86, without the need for negative levels: 0 being the lower and 3 highest. Higher levels tend to be created more often than lower ones.
The current EL can be queried with the MRS instruction: what is the current execution mode/exception level, etc?
ARM does not require all exception levels to be present to allow for implementations that don't need the feature to save chip area. ARMv8 "Exception levels" says:
An implementation might not include all of the Exception levels. All implementations must include EL0 and EL1. EL2 and EL3 are optional.
QEMU for example defaults to EL1, but EL2 and EL3 can be enabled with command line options: qemu-system-aarch64 entering el1 when emulating a53 power up
Code snippets tested on Ubuntu 18.10.
2/5
Top Answer
Answered Nov 03, 2010 · 4 votes
First, in this context a channel is a path for sensitive data (what you're trying to protect or keep secret) to escape through. Fundamentally it is about who knows about it (whether the leakage is intentional or accidental)
A covert channel is a channel that is hidden. This means that its existence is intentional, and additionally there is an intention to conceal or hide its existence from a person who is trying to protect the system by filtering or limiting data flow. As an example, steganography.
A side-channel is a channel that exists incidentally to the otherwise secure flow of data, and is described by Andrew Cooper.
3/5
Objective-C is a language versatile and sophisticated enough for iOS and Mac OS GUI programming. One Objective-C feature that can be called both flexible and dynamic is the use of protocols. Protocols help in the creation of interfaces where a class implementation needs to follow a set of methods and properties.
Table of Content
- What are the Protocols in Objective-C?
- Types of Protocols in Objective-C
- Syntax and Keywords
- Examples
- Conclusion
What are the Protocols in Objective-C?A protocol is a normative approach to constrain a set of classes that may require a common interface, for instance, delegates, data sources, and observers.
- This approach can also integrate secondary, or multiple, inheritance which is not permitted when working with Cocoa classes.
- A single class can be responsible for multiple protocols, which means it can easily adapt the behavior of several other classes without necessarily subclassing these classes.
Types of Protocols in Objective-CThere are two types of protocols in Objective-C, formal and informal protocols.
Formal ProtocolsIn the formal protocol declaration, the name of the protocol and its methods and properties are used after the prefix @protocol. Protocols declare methods and properties with modifiers, like @required or @optional, to indicate the needed implementation by the classes that accept the protocol. After this, the @end statement must appear. It marks the end of the protocol declaration.
For instance, the below code defines an arbitrary protocol called PrintProtocolDelegate, specifically, in which it declares a single necessary method called processCompleted.
-@protocol PrintProtocolDelegate@requiredvoid processCompleted...
- “Categories are a way of adding methods to the existing class without its subclassing” – groups methods that don’t add new behaviors to the original class.
- A non-official protocol is a list of rules that are not required by classes to implement, but they are expected to be available while the classes are under execution.
- They are however checked by the compiler, therefore programs may contain the methods even though the particular classes that are accepting them do not implement them at all.
- They don’t correspond to the function declarations as returned by the header files so they are substantially more difficult to identify and apply.
- These collisions result from the repeated use of names that are the same but possess various signatures or connotations.
4/5
Top Answer
Answered Aug 28, 2008 · 18 votes
The SMTP server at Gmail (which accepted the message from Thunderbird) will route the message to the final recipient.
It does this by using DNS to find the MX (mail exchanger) record for the domain name part of the destination email address (hotmail.com in this example). The DNS server will return an IP address which the message should be sent to. The server at the destination IP address will hopefully be running SMTP (on the standard port 25) so it can receive the incoming messages.
Once the message has been received by the hotmail server, it is stored until the appropriate user logs in and retrieves their messages using POP (or IMAP).
Jason - to answer your follow up...
Then, SOMESERVER uses SMTP again to send the message to RECEIVESERVER.com on port 25 (not smtp.mail.RECEIVESERVER.com or anything fancy).
That's correct - the domain name to send to is taken as everything after the '@' in the email address of the recipient. Often, RECEIVESERVER.com is an alias for something more specific, say something like incoming.RECEIVESERVER.com, (or, indeed, smtp.mail.RECEIVESERVER.com).
You can use nslookup to query your local DNS servers (this works in Linux and in a Windows cmd window):
nslookup> set type=mx> stackoverflow.comServer: 158.155.25.16Address: 158.155.25.16#53-Non-authoritative answer:stackoverflow.com mail exchanger = 10 aspmx.l.google.com.stackoverflow.com mail exchanger = 20 alt1.aspmx.l.google.com.stackoverflow.com mail exchanger = 30 alt2.aspmx.l.google.com.stackoverflow.com mail exchanger = 40 aspmx2.googlemail.com.stackoverflow.com mail exchanger = 50 aspmx3.googlemail.com.-Authoritative answers can be found from:aspmx.l.google.com internet address = 64.233.183.114aspmx.l.google.com internet address = 64.233.183.27> -
This shows us that email to anyone at stackoverflow.com should be sent to one of the gmail servers shown above.
The Wikipedia article mentioned (http://en.wikipedia.org/wiki/Mx_record) discusses the priority numbers shown above (10, 20, ..., 50).
Other Answers
Answered Jun 20, 2020 · 5 votes
You're looking for the Mail Transfer Agent, Wikipedia has a nice article on the topic.
Within Internet message handling services (MHS), a message transfer agent or mail transfer agent (MTA) or mail relay is software that transfers electronic mail messages from one computer to another using a client–server application architecture. An MTA implements both the client (sending) and server (receiving) portions of the Simple Mail Transfer Protocol.
The terms mail server, mail exchanger, and MX host may also refer to a computer performing the MTA function. The Domain Name System (DNS) associates a mail server to a domain with mail exchanger (MX) resource records containing the domain name of a host providing MTA services.
Other Answers
Answered Mar 06, 2021 · 5 votes
You might also be interested to know why the GMail to HotMail link uses SMTP, just like your Thunderbird client. In other words, since your client can send email via SMTP, and it can use DNS to get the MX record for hotmail.com, why doesn't it just send it there directly, skipping gmail.com altogether?
There are a couple of reasons, some historical and some for security. In the original question, it was assumed that your Thunderbird client logs in with a user name and password. This is often not the case. SMTP doesn't actually require a login to send a mail. And SMTP has no way to tell who's really sending the mail. Thus, spam was born!
There are, unfortunately, still many SMTP servers out there that allow anyone and everyone to connect and send mail, trusting blindly that the sender is who they claim to be. These servers are called "open relays" and are routinely black-listed by smarter administrators of other mail servers, because of the spam they churn out.
Responsible SMTP server admins set up their server to accept mail for delivery only in special cases 1) the mail is coming from "its own" network, or 2) the mail is being sent to "its own" network, or 3) the user presents credentials that identifies him as a trusted sender. Case #1 is probably what happens when you send mail from work; your machine is on the trusted network, so you can send mail to anyone. A lot of corporate mail servers still don't require authentication, so you can impersonate anyone in your office. Fun! Case #2 is when someone sends you mail. And case #3 is probably what happens with your GMail example. You're not coming from a trusted network, you’re just out on the Internet with the spammers. But by using a password, you can prove to GMail that you are who you say you are.
The historical aspect is that in the old days, the link between gmail and hotmail was likely to be intermittent. By queuing your mail up at a local server, you could wash your hands of it, knowing that when a link was established, the local server could transfer your messages to the remote server, which would hold the message until the recipient's agent picked it up.
5/5
People also ask
What is a protocol in a computer network?
- It can also be defined as a communication standard followed by the two key parties (sender and receiver) in a computer network to communicate with each other. It specifies what type of data can be transmitted, what commands are used to send and receive data, and how data transfers are confirmed. In simple terms, a protocol is similar to a language.
What are Protocols and what are the key elements of protocols?
afteracademy.com/blog/what-are-protocols-and-what-are-the-key-elements-of-protocols/What is a protocol & how does it work?
- So, let's get started with the basics of protocols. Protocols are a fundamental aspect of digital communication as they dictate how to format, transmit and receive data. They are a set of rules that determines how the data will be transmitted over the network.
What are Protocols and what are the key elements of protocols?
afteracademy.com/blog/what-are-protocols-and-what-are-the-key-elements-of-protocols/What are the three main tasks a network protocol performs?
- Secured connections, network management, and network communication are the three main tasks that the network protocol performs. The purpose of protocols is to link different devices. The protocols can be broadly classified into three major categories: 1. Network Communication
Types of Network Protocols and Their Uses - GeeksforGeeks
www.geeksforgeeks.org/types-of-network-protocols-and-their-uses/What is a communication protocol?
- A communication protocol is a system of rules that allows two or more entities of a communications system to transmit information via any variation of a physical quantity. The protocol defines the rules, syntax, semantics, and synchronization of communication and possible error recovery methods.
Communication protocol - Wikipedia
en.wikipedia.org/wiki/Communication_protocolwww.cloudflare.com › learning › network-layerWhat is a protocol? | Network protocol definition | Cloudflare
www.cloudflare.com › learning › network-layerIn networking, a protocol is a set of rules for formatting and processing data. Network protocols are like a common language for computers. The computers within a network may use vastly different software and hardware; however, the use of protocols enables them to communicate with each other regardless. Standardized protocols are like a common ...
www.techtarget.com › searchnetworking › definitionWhat is a Network Protocol? Definition and Types | TechTarget
www.techtarget.com › searchnetworking › definitionA network protocol is a set of established rules that specify how to format, send and receive data so that computer network endpoints, including computers, servers, routers and virtual machines, can communicate despite differences in their underlying infrastructures, designs or standards.
www.geeksforgeeks.org › types-of-network-protocolsTypes of Network Protocols and Their Uses - GeeksforGeeks
www.geeksforgeeks.org › types-of-network-protocolsMay 22, 2024 · Network protocols are a set of rules that are responsible for the communication of data between various devices in the network. These protocols define guidelines and conventions for transmitting and receiving data, ensuring efficient and reliable data communication. What is Network Protocol?
afteracademy.com › blog › what-are-protocols-andWhat are Protocols and what are the key elements of protocols?
afteracademy.com › blog › what-are-protocols-andDec 6, 2019 · Protocols are a fundamental aspect of digital communication as they dictate how to format, transmit and receive data. They are a set of rules that determines how the data will be transmitted over the network.
en.wikipedia.org › wiki › Communication_protocolCommunication protocol - Wikipedia
en.wikipedia.org › wiki › Communication_protocolA communication protocol is a system of rules that allows two or more entities of a communications system to transmit information via any variation of a physical quantity. The protocol defines the rules, syntax, semantics, and synchronization of communication and possible error recovery methods.
www.lifewire.com › computer-networks-protocols-817374How Do Computer Network Protocols Work? - Lifewire
www.lifewire.com › computer-networks-protocols-817374Jun 29, 2021 · Computer network protocols serve as the language method by which devices can communicate with each other over shorter or longer distances.
www.linuxpourlesnuls.org › networking-protocolsNetworking Protocols: The Role in Operating Systems
www.linuxpourlesnuls.org › networking-protocolsJul 31, 2023 · How does this seamless transfer of data happen? The answer lies in networking protocols – the set of rules that govern how computers communicate with each other over networks. Networking protocols play a crucial role in operating systems by enabling efficient and reliable data transmission between devices.
Searches related to what are protocols in operating systems in computer