I have my working pc and a laptop. On the pc I running Windows with domain controller account. When I log on I have access to the Internet. My laptop connected to the same network with Ubuntu operating system. Are there any ways to obtain the Internet access from my laptop? Now i'm simply using remote desktop connection from lap top, but I really need the Internet on my Ubuntu.
IP configuration Windows
HOST NAME . . . . .. . . . . . : MN10384632
DNS . . . . . . . . . . . . . : bs.idest.ru
DNS LOOKUP ORDER. . . . . . . . : bs.idest.ru
idest.ru
LAN - Ethernet:
DNS. . . . . . . . . . . . . . . :
DESCRIPTION . . . . . . . . . . . . : Broadcom NetXtreme Gigabit Ethernet
Dhcp Enabled.. . . . . . . . . .. . . . : disabled
IP-address .. . . . . . . . . . . . . . : 10.1.25.6
Network mask . . . . . . . . . . . . . : 255.255.255.0
Gateway . . .. . . . . . . . . . . .. : 10.1.25.1
DNS. . . . . . . . . . . . . . . . . . . : 10.1.10.4
10.1.10.5
WINS-server . . . . . . . . . . . . . .: 192.168.100.110
GENERAL.DEVICE: enp3s0
GENERAL.TYPE: ethernet
GENERAL.HWADDR: MYMAC
GENERAL.MTU: 1500
GENERAL.STATE: 100 (connected)
GENERAL.CONNECTION: CORPORATE
GENERAL.CON-PATH: /org/freedesktop/NetworkManager/ActiveConnection/83
WIRED-PROPERTIES.CARRIER: on
IP4.ADDRESS[1]: 10.1.25.106/24
IP4.GATEWAY: 10.1.25.1
IP4.DNS[1]: 10.1.10.4
IP4.DNS[2]: 10.1.10.5
Most probably, if you have no rights there is nothing you can do. You need at least to enable routing and NAT on your Windows...
Related
I'm trying to print out a board in the right way, like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
1. . . . . . . . . . . . . . . . . .
2. . . . . . . . . . . . . . . . . .
3. . . . . . . . . . . . . . . . . .
4. . . . . . . . . . . . . . . . . .
5. . . . . . . . . . . . . . . . . .
6. . . . . . . . . . . . . . . . . .
7. . . . . . . . . . . . . . . . . .
8. . . . . . . . . . . . . . . . . .
9. . . . . . . . . . . . . . . . . .
10. . . . . . . . . . . . . . . . . .
11. . . . . . . . . . . . . . . . . .
12. . . . . . . . . . . . . . . . . .
13. . . . . . . . . . . . . . . . . .
14. . . . . . . . . . . . . . . . . .
15. . . . . . . . . . . . . . . . . .
16. . . . . . . . . . . . . . . . . .
17. . . . . . . . . . . . . . . . . .
18. . . . . . . . . . . . . . . . . .
I have the list comprehension here
((concat [(""++show i)++" " | i <- [1..n], i<10])++"\n")
I can get the 9 first numbers correctly, but the problem comes when i would like to put an else statement in my comprehension. I can't seem to know how to do that. So to make my self extra clear, i would like to do the same thing with the double digits but the only difference will be that i want two spaces instead of three between each double digit.
The left hand of the list comprehension accepts any Haskell expression, so we can write the if-then-else in the left hand of the list comprehension and omit the i < 10 condition on the right hand:
concat [(""++show i)++if i < 10 then " " else " " | i <- [1..n]]++"\n"
For n = 15, this then produces:
Prelude> concat [(""++show i)++if i < 10 then " " else " " | i <- [1..n]]++"\n"
"1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 \n"
We can also remove the ""++ part on the left side of the list comprehension, since this is bascially a no operation:
concat [show i ++ if i < 10 then " " else " " | i <- [1..n]] ++ "\n"
The above is however not very elegant: if i = 123, then we still will run into trouble. We can calculate the length of the show, calculate 4-l (with l the length), and add this as extra spacing. For instance:
concat [s ++ replicate (4-length s) ' ' | i <- [1..n], let s = show i] ++ "\n"
There are also some more dedicated formatting and joining functions, but since the exercise is probably to get familier with lists, I think this is out of scope here.
Like #4castle says, we can use for instance printf:
import Text.Printf(printf)
concatMap (printf "%-4d") [1..n] ++ "\n"
Wasn't able to find anything related so here goes! :D
Inside Redhat terminal, whenever I do a ping towards a Redhat virtIO Ethernet Adapter interface of Windows it results to DUP! responses.
I've tried pinging either one of those two virtIO interfaces and both yields to duplicate ping responses...
I've read somewhere that it may be due to Windows' RRAS
Though I'm afraid that turning this off would disable also my capability to Remote access via RDP to this Windows machine.
So does anybody encountered this?
Windows interface setup:
Windows IP Configuration
Host Name . . . . . . . . . . . . . . . . : G162401EN
Primary Dns Suffix . . . . . . . . . . . :
Node Type . . . . . . . . . . . . . . . . : Hybrid
IP Routing Enabled . . . . . . . . . . . : No
WINS Proxy Enabled . . . . . . . . . . . : No
Ethernet Adapter EXT-CP2-EL5:
Connection-specific DNS Suffix . . . . . :
Description . . . . . . . . . . . . . . . : Red Hat VirtIO Ethernet Adapter #5
Physical Address . . . . . . . . . . . . : F0:X:Y:Z:A:B
DHCP Enabled . . . . . . . . . . . . . . : No
Autoconfiguration Enabled . . . . . . . . : Yes
IPv4 Address . . . . . . . . . . . . . . : 10.40.90.163(Preferred)
Subnet Mask . . . . . . . . . . . . . . . : 255.255.255.224
Default Gateway . . . . . . . . . . . . . :
NetBIOS over Tcpip . . . . . . . . . . . : Enabled
Ethernet Adapter EXT-CP1-EL4:
Connection-specific DNS Suffix . . . . . :
Description . . . . . . . . . . . . . . . : Red Hat VirtIO Ethernet Adapter #4
Physical Address . . . . . . . . . . . . : F0:D:E:F:G:H
DHCP Enabled . . . . . . . . . . . . . . : No
Autoconfiguration Enabled . . . . . . . . : Yes
IPv4 Address . . . . . . . . . . . . . . : 10.40.90.131(Preferred)
Subnet Mask . . . . . . . . . . . . . . . : 255.255.255.224
Default Gateway . . . . . . . . . . . . . :
NetBIOS over Tcpip . . . . . . . . . . . : Enabled
I am kinda new to MPI, so forgive me if it is a trivial question. I have a quad core CPU. And I want to run an OpenMPI C++ program that uses two processes on a single core. Is there any way to do so? If so, then how? I referred to this link on stack overflow which, most probably, says that there might be a way... If so, then how can I do it?
Since MPI spawns separate processes, the scheduling of processes onto cores is generally/usually performed by your operating system. You can still achieve what you want by manually setting the affinity of the processes to a specific core.
You can do this in Linux using the sched_setaffinity function.
To pin a process to a specific core, you can use the following approach:
#include <mpi.h>
#include <sched.h>
// ...
void pin_to_core(int cpuid) {
cpu_set_t set;
CPU_ZERO(&set);
CPU_SET(cpuid,&set);
sched_setaffinity(0,sizeof(cpu_set_t),&set);
}
// ....
int main(int argc, char* argv[]) {
MPI_Init(&argc, &argv);
pin_to_core(0); // pin process to core 0
// ...
MPI_Finalize();
}
Make sure to call this function after you call MPI_Init in your main function and specify the core you want to pin the process to.
The proper way to implement this with Open MPI is to provide a rankfile which tells the library where to place each process. The following rankfile should suffice in your case:
rank 0=localhost slot=0
rank 1=localhost slot=0
It tells Open MPI that both ranks should run on the local host and be bound to OS CPU 0, which is usually the first core. Provide the rankfile in addition to the hostfile or the host list:
$ mpiexec --host localhost --report-bindings --rankfile ./rankfile -np 2 hostname
[cluster:03247] MCW rank 0 bound to socket 0[core 0]: [B . . . . . . .][. . . . . . . .][. . . . . . . .][. . . . . . . .][. . . . . . . .][. . . . . . . .][. . . . . . . .][. . . . . . . .] (slot list 0)
[cluster:03247] MCW rank 1 bound to socket 0[core 0]: [B . . . . . . .][. . . . . . . .][. . . . . . . .][. . . . . . . .][. . . . . . . .][. . . . . . . .][. . . . . . . .][. . . . . . . .] (slot list 0)
cluster
cluster
I'm looking for a way to remove the returns from the following function:
naming path =
getModificationTime path >>=
return . formatTime defaultTimeLocale "%Y%m%d" >>=
return . printf "%s_%s" (takeBaseName path) >>=
return . replaceBaseName path
The reason why I structure it this way is because >>= essentially becomes kind of a pipe operator and data flows from one line to the next.
I figured I can define an operator along the lines of
a |>= b = (return a) >>= b
and get
naming path =
getModificationTime path >>=
formatTime defaultTimeLocale "%Y%m%d" |>=
printf "%s_%s" (takeBaseName path) |>=
replaceBaseName path
but I get the error
Precedence parsing error
cannot mix `|>=' [infixl 9] and `.' [infixr 9] in the same infix expression
What's the best way to resolve this issue? Better yet, is there some sort of standard operator or other way to make it easier to structure the code this way?
Presumably you want it to behave with the same fixity as >>=, so if you load up GHCi and type
> :info (>>=)
...
infixl 1 >>=
You could then define your operator as
infixl 1 |>=
(|>=) :: Monad m => a -> (a -> m b) -> m b
a |>= b = return a >>= b
But, if your monad preserves the monad laws, this is identical to just doing b a, so there isn't really a need for the operator in the first place.
I'd also suggest using do notation:
naming path = do
modTime <- getModificationTime path
let str = formatTime defaultTimeLocale "%Y%m%d" modTime
name = printf "%s_%s" (takeBaseName path) str
replaceBaseName path name
You need the return because the whole rest of your chain composes pure functions, so the best way is to use the normal function composition operator .. However, . composes in the different direction compared to >>= and since >>= is meant for composing two monadic operations you'll need at least one return:
naming path =
getModificationTime path >>=
return .
replaceBaseName path .
printf "%s_%s" (takeBaseName path) .
formatTime defaultTimeLocale "%Y%m%d"
One way to get rid of the extra return is to use <**> and pure from Control.Applicative instead of >>=.
naming path =
getModificationTime path <**> pure (
replaceBaseName path .
printf "%s_%s" (takeBaseName path) .
formatTime defaultTimeLocale "%Y%m%d" )
To "fix" the order of operations to flow from top to bottom, we can replace . with >>> from Control.Category, giving
naming path =
getModificationTime path <**> pure (
formatTime defaultTimeLocale "%Y%m%d" >>>
replaceBaseName path >>>
printf "%s_%s" (takeBaseName path) )
Or, if you want to get crazy (using Control.Arrow):
naming path = flip runKleisli path $
Kleisli getModificationTime >>^
formatTime defaultTimeLocale "%Y%m%d" >>^
replaceBaseName path >>^
printf "%s_%s" (takeBaseName path)
Unfortunately, Control.Applicative doesn't provide a flipped version of <$>, but you can define it yourself to get a tidier version:
(<$$>) = flip (<$>)
infixr 1 <$$>
naming path =
getModificationTime path <$$>
formatTime defaultTimeLocale "%Y%m%d" >>>
replaceBaseName path >>>
printf "%s_%s" (takeBaseName path)
At which point we could just do this:
(|>=) = flip fmap
naming path =
getModificationTime path |>=
formatTime defaultTimeLocale "%Y%m%d" |>=
printf "%s_%s" (takeBaseName path) |>=
replaceBaseName path
return x >>= f is the same as f x---in other words, most of your inner functions are pure and don't need (>>=) at all. Inside of do notation you use let to bind pure computations.
naming path = do
time <- getModificationTime path
let str = formatTime defaultTimeLocale "%Y%m%d" time
name = printf "%s_%s" (takeBaseName path) str
replaceBaseName path name
To be even more concise, name above could be computed inline
naming path = do
time <- getModificationTime path
replaceBaseName path
$ printf "%s_%s" (takeBaseName path)
$ formatTime defaultTimeLocale "%Y%m%d" time
And we see that we're just doing some pure function composition, so we can use (.)
naming path =
getModificationTime path >>= replaceBaseName path . mkTime
where
mkTime = printf "%s_%s" (takeBaseName path)
. formatTime defaultTimeLocale "%Y%m%d"
If we didn't need path for getModificationTime, replaceBaseName, and takeBaseName we could shorten it even more by using just (>=>) to remove the path point entirely. That could still be done by using the ReaderT monad transformer, but it's likely to get uglier instead of nicer at this rate.
How can I Use semaphores to describe the synchronization of the eight processes in the general
precedence graph above?
p1 p2 p3 p4 p5 p6 p7 p8
=============================================================================
. . . . . . . .
work . . . . . . .
| . . . . . . .
V(s1, 3) P(s1) . . P(s1) . P(s1) .
x | . . | . | .
work . . | . | .
| . . | . | .
V(s2, 2) P(s2) P(s2) work . | .
x | | | . | .
| work | . work .
| | | . | .
work V(s3, 1) V(s3, 1) P(s3) | .
| x x P(s3) | .
| | | .
| work | .
| | | .
V(s4, 1) V(s4, 1) V(s4, 1) P(s4)
x x x P(s4)
P(s4)
|
work
|
x